1
$\begingroup$

I have a simple net:

net = NetInitialize@
  NetChain[{LinearLayer[2], SoftmaxLayer[]}, "Input" -> 2, 
   "Output" -> NetDecoder[{"Class", {0, 1}}]]

net@RandomReal[{-1, 1}, {10, 2}]

How do I return probabilites after SoftmaxLayer? Right now I have to insert dummy ElementwiseLayer[Identity] in the end of a chain and then Take[net,2] would return what I actually need.

$\endgroup$
2

1 Answer 1

2
$\begingroup$

maybe you can try this:

num=RandomReal[{-1, 1}, {10, 2}];
net[num,"Probabilities"]

enter image description here

And there is a new function NetDrop in 11.3.0, you can check:

SoftmaxLayer["Input" -> 2]@NetDrop[net, -1][num]

enter image description here

Exactly the same.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.