Why ignored label appeared in prediction map?
Surflyan opened this issue · 9 comments
there are some pixels predict to undefined as first column shows, but undefined label has ignored. how to solve ?
Maybe you can reference to model.py/get_model function.
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.
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.
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.
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.
- in the main.py line 170
modifyN_CLASSES = len(LABEL_VALUES)
toN_CLASSES = len(LABEL_VALUES) - len(IGNORED_LABELS)
- in the model.py
line 36 comment out this line
# weights[torch.LongTensor(kwargs['ignored_labels'])] = 0.
line 998 1003 1138
addtarget = target - 1
- in the utils.py
metrics function line 304
modifytarget = target[ignored_mask]
totarget = target[ignored_mask] -1
show_results function line 365
addlabel_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.
Thanks for your reply, I will try as you suggest. Your job is helpful for me.
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.
- in the main.py line 170
modifyN_CLASSES = len(LABEL_VALUES)
toN_CLASSES = len(LABEL_VALUES) - len(IGNORED_LABELS)
- in the model.py
line 36 comment out this line
# weights[torch.LongTensor(kwargs['ignored_labels'])] = 0.
line 998 1003 1138
addtarget = target - 1
- in the utils.py
metrics function line 304
modifytarget = target[ignored_mask]
totarget = target[ignored_mask] -1
show_results function line 365
addlabel_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!
Sorry, it took so long to reply. I will verify the current code and fix the problem as soon as possible.
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.
- in the main.py line 170
modifyN_CLASSES = len(LABEL_VALUES)
toN_CLASSES = len(LABEL_VALUES) - len(IGNORED_LABELS)
- in the model.py
line 36 comment out this line
# weights[torch.LongTensor(kwargs['ignored_labels'])] = 0.
line 998 1003 1138
addtarget = target - 1
- in the utils.py
metrics function line 304
modifytarget = target[ignored_mask]
totarget = target[ignored_mask] -1
show_results function line 365
addlabel_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