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

1 次查看(过去 30 天)
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!

采纳的回答

Matheus Ferreira
Matheus Ferreira 2020-6-24
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by