Can I use "softmaxLayer" for regression network?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 19 Apr. 2018
Bearbeitet: MathWorks Support Team
am 26 Mär. 2019
Can I use "softmaxLayer" for regression network?
Akzeptierte Antwort
MathWorks Support Team
am 26 Mär. 2019
Bearbeitet: MathWorks Support Team
am 26 Mär. 2019
A softmax layer normalizes the input to the layer such that its elements sum up to 1. Therefore, it is useful when you want the network to compute a probability of a classification problem, since it ensures that the sum of the scores over the classes is 1, as requested for a probability measure.
However, it can be used also in combination with other layers as long as it makes sense to normalize the inputs to sum up to 1.
Thus, you can use "softmaxLayer" in MATLAB for your regression problem (although assessing its effectiveness would depend on the problem you are trying to solve at hand).
For example, you can create the following deep learning network:
>> layers = [ ...
>> imageInputLayer([28 28 1]), ...
>> convolution2dLayer(12,25), ...
>> softmaxLayer, ...
>> fullyConnectedLayer(1), ...
>> regressionLayer]
Currently, a"softmaxLayer" cannot directly precede a "regressionLayer", which is why a "fullyConnectedLayer" is between the two in the above example. However, another workaround would be to define a custom regression output layer and a custom softmax layer. If you use a custom layers instead of the layers provided in the Deep Learning Toolbox, you can have a softmax layer immediately before a regression layer.
Here is what the "layers" array in the above example would look like using custom layers called "mySoftmaxLayer" and "myRegressionLayer":
>> layers = [ ...
>> imageInputLayer([28 28 1]), ...
>> convolution2dLayer(12,25), ...
>> mySoftmaxLayer, ...
>> myRegressionLayer]
For instructions and an example on how to define a custom regression output layer, please view the documentation page linked here:
For instructions and an example on how to define a custom layer with learnable parameters, please refer to the documentation page linked here:
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!