Is SoftmaxLayer broken in version 11.3.0.0? I know, it's probably me. Here's a MWE of the issue.
Note that this works fine if e.g. Exp is substituted for SoftmaxLayer[].
It works if you explicitly specify the loss function:
NetTrain[testnet, {{1, 2} -> {0.2, 0.8}},
LossFunction -> CrossEntropyLossLayer["Binary"]]
The default is Automatic
, which chooses CrossEntropyLossLayer["Index"]
and expects indices as training targets.
From the documentation of LossFunction:
When a loss layer is chosen automatically for a port, the loss layer to use is based on the layer within the net whose output is connected to the port, as follows:
SoftmaxLayer[]
-> useCrossEntropyLossLayer["Index"]
ElementwiseLayer[LogisticSigmoid]
-> useCrossEntropyLossLayer["Binary"]
NetPairEmbeddingOperator[]
-> useContrastiveLossLayer[]
other non-loss layers -> use
MeanSquaredLossLayer[]
loss layers -> use unchanged