How to change the default loss function from "crossentropyex" to "crossentropy" using the pixelClassificationLayer in MATLAB?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gobert
le 13 Juil 2023
Modifié(e) : Malay Agarwal
le 13 Juil 2023
Hi,
The properties of the pixelClassificationLayer include the LossFunction "crossentropyex" by default. When I attempted to change it as shown below:
SegLayer = pixelClassificationLayer('LossFunction', 'crossentropy');
I encountered the following error:
Error using nnet.cnn.layer.PixelClassificationLayer.parseInputs 'LossFunction' is not a recognized parameter.
Could you please demonstrate how to modify the default loss function? I am using the Unet model for semantic segmentation, and I want to switch from "crossentropyex" to "crossentropy" because the former is only suitable for mutually exclusive scenarios.
Thank you!
0 commentaires
Réponse acceptée
Malay Agarwal
le 13 Juil 2023
Modifié(e) : Malay Agarwal
le 13 Juil 2023
Unfortunately, the LossFunction property of the pixelClassificationLayer is read-only and cannot be changed. What you can do instead is create a custom pixel classification layer, as demonstrated here: Define Custom Pixel Classification Layer with Tversky Loss - MATLAB & Simulink - MathWorks India. The example demonstrates how to use the Tversky loss but it shouldn't be too difficult to adapt the example to use the crossentropy loss. Please make sure you use functions supported by dlarray to make use of automatic differentiation.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!