Can I use "softmaxLayer" for regression network?
2 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2018-4-19
编辑: MathWorks Support Team
2019-3-26
Can I use "softmaxLayer" for regression network?
采纳的回答
MathWorks Support Team
2019-3-26
编辑:MathWorks Support Team
2019-3-26
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!