How to make the layer automatically ignores a given pixel label during network training?

1 view (last 30 days)
I would like to train a semantic segmentation network without considering a given class label during training. I want that pixels from that class do not propagate the loss.
I want to implement a cross-entropy loss function similar to this Python example. The function ignores the last label during loss computation so the network does not "learn" to classify a given class, although this class is present in the training patch.
I know about the dicePixelClassificationLayer function that says "The layer automatically ignores undefined pixel labels during training.", but how to set a given class label to "undefined" so that the layer automatically ignores it?
Please help!

Accepted Answer

Matheus Ferreira
Matheus Ferreira on 24 Jun 2020
Already solved: Just use the standardizeMissing function to substitut the ID of a given class by NaN. For example, if the class label to ignore is 99 run the following:
img = standardizeMissing(img,99);
Save variable img to the TIFF format and create a pixelLabelDatastore with the class names and label IDs without the class 99, for example. The pixels os the class 99 will be converted to <undefined> and the pixelClassificationLayer ignores undefined pixel labels during training.

More Answers (0)

Categories

Find more on Image Data Workflows in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!