add spatialdropoutlayer (class) to Simulink.
5 views (last 30 days)
Show older comments
I created a 1D CNN network including a "spatialdropoutlayer" which is in the form of class (.m file). I want to integrate this trained CNN in Simulik, convert to C and update to a controller. when I added the trained network to the stateful classify block, it errors that can't read the spatialdropoutlayer.
How can I solve the issue? Is there a way to call the class to the Simulink? Is there any other block that can be recieve the CNN and layer?
2 Comments
Walter Roberson
on 25 Mar 2025
I was going to suggest,
If you are using a dlnetwork then you can use exportNetworkToSimulink() https://www.mathworks.com/help/deeplearning/ref/dlnetwork.exportnetworktosimulink.html
However, I see in the list of supported layers https://www.mathworks.com/help/deeplearning/ug/list-of-deep-learning-layer-blocks.html that spatialDropoutLayer is not one of the supported layers (but dropoutLayer is supported but does nothing in the converted network.)
Walter Roberson
on 25 Mar 2025
I was going to suggest,
Create and train a dlnetwork in MATLAB, and save() it to a .mat file.
Then in Simulink, use a Simulink Predict block https://www.mathworks.com/help/deeplearning/ref/predict.html
However, dlnetwork are only useful for prediction, not for classification
Answers (1)
Katja Mogalle
on 29 Apr 2025
Dropout is typically only used during the training phase to make the network generalize better and make it more robust. During inference, the dropout layers don't do anything (as Walter indicated in his first response). So one solution would be to remove the dropout layer before exporting the network to Simulink. You can do this removel in the Deep Network Designer app or in the command line using the functions removeLayers and connectLayers.
Alternatively, you could use the predict block in Simulink (as mentioned by Walter). Here an example that also shows how to get the classification results: https://uk.mathworks.com/help/deeplearning/ug/classify-images-in-simulink-with-imported-tensorflow-network.html
0 Comments
See Also
Categories
Find more on Sequence and Numeric Feature 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!