Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why ignored label appeared in prediction map? #5

Open
Surflyan opened this issue Aug 20, 2019 · 9 comments
Open

Why ignored label appeared in prediction map? #5

Surflyan opened this issue Aug 20, 2019 · 9 comments

Comments

@Surflyan
Copy link

image

@Surflyan
Copy link
Author

there are some pixels predict to undefined as first column shows, but undefined label has ignored. how to solve ?

@eecn
Copy link
Owner

eecn commented Nov 16, 2019

Maybe you can reference to model.py/get_model function.
image

The number of categories we use in the model definition is the actual number of categories plus one (including undefined data). Actually, the training data does not contain undefined data during the supervised training process, but the undefined category is included in the prediction process with the defined model.

@eecn
Copy link
Owner

eecn commented Nov 16, 2019

So the confusion matrix contains a row of all zero vectors (actually the target does not contain undefined categories), and the prediction contains the actual number of categories +1.

@eecn eecn added the invalid This doesn't seem right label Nov 19, 2019
@eecn
Copy link
Owner

eecn commented Nov 20, 2019

In my opinion,at main.py line 170
N_CLASSES = len(LABEL_VALUES) which include the undefined label .
at model.py line 33
n_classes = kwargs['n_classes'] so our model try to learn actual classes+ 1categories.
Take PU data as an example,the target is in [1,9],but the prediction is in [0,9].That why the confusion matrix looks like that.
But ,in the get_model function we set weights[torch.LongTensor(kwargs['ignored_labels'])] = 0. which pass to 'criterion' and it will not have influence on loss.

@eecn
Copy link
Owner

eecn commented Nov 20, 2019

This project is designed to construct a common framework, so it is designed to be compatible with the requirements of full supervision and semi-supervised learning, so it is not as intuitive as a normal network. If you want to carry out ordinary supervised training, you can modify the following points to achieve.

  1. in the main.py line 170
    modify N_CLASSES = len(LABEL_VALUES)to N_CLASSES = len(LABEL_VALUES) - len(IGNORED_LABELS)
  2. in the model.py
    line 36 comment out this line
    # weights[torch.LongTensor(kwargs['ignored_labels'])] = 0.
    line 998 1003 1138
    add target = target - 1
  3. in the utils.py
    metrics function line 304
    modify target = target[ignored_mask] to target = target[ignored_mask] -1
    show_results function line 365
    add label_values = label_values[1:]
    This is just to provide a method to solve the issue you raised.And i will try to make the project more valid in the feature.Thanks for your attention.

@Surflyan
Copy link
Author

@Surflyan

Thanks for your reply, I will try as you suggest. Your job is helpful for me.

@eecn eecn removed the invalid This doesn't seem right label Nov 28, 2019
@HaynesDing
Copy link

This project is designed to construct a common framework, so it is designed to be compatible with the requirements of full supervision and semi-supervised learning, so it is not as intuitive as a normal network. If you want to carry out ordinary supervised training, you can modify the following points to achieve.

  1. in the main.py line 170
    modify N_CLASSES = len(LABEL_VALUES)to N_CLASSES = len(LABEL_VALUES) - len(IGNORED_LABELS)
  2. in the model.py
    line 36 comment out this line
    # weights[torch.LongTensor(kwargs['ignored_labels'])] = 0.
    line 998 1003 1138
    add target = target - 1
  3. in the utils.py
    metrics function line 304
    modify target = target[ignored_mask] to target = target[ignored_mask] -1
    show_results function line 365
    add label_values = label_values[1:]
    This is just to provide a method to solve the issue you raised.And i will try to make the project more valid in the feature.Thanks for your attention.

When i follow the steps and run it ,i found that the Confusion matrix data become wrong.The first number of each line is 0. I tried to find out the reason and modified it, but I failed.Hope you can help me, thank you!

@eecn
Copy link
Owner

eecn commented Jul 15, 2020

Sorry, it took so long to reply. I will verify the current code and fix the problem as soon as possible.

@leiqing110
Copy link

This project is designed to construct a common framework, so it is designed to be compatible with the requirements of full supervision and semi-supervised learning, so it is not as intuitive as a normal network. If you want to carry out ordinary supervised training, you can modify the following points to achieve.

  1. in the main.py line 170
    modify N_CLASSES = len(LABEL_VALUES)to N_CLASSES = len(LABEL_VALUES) - len(IGNORED_LABELS)
  2. in the model.py
    line 36 comment out this line
    # weights[torch.LongTensor(kwargs['ignored_labels'])] = 0.
    line 998 1003 1138
    add target = target - 1
  3. in the utils.py
    metrics function line 304
    modify target = target[ignored_mask] to target = target[ignored_mask] -1
    show_results function line 365
    add label_values = label_values[1:]
    This is just to provide a method to solve the issue you raised.And i will try to make the project more valid in the feature.Thanks for your attention.

Your answer helped me solve the problem, thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants