I've been playing with Mathematica's neural network functions, and I keep getting stuck on the same annoying problem. Often Mathematica declares that the output of my neural network is a vector of size 1, rather than a scalar. The only way around this problem I found is to train an uninitialized network with scalar expected output, and then the network has output "scalar". But sometimes I can't do this, for example I have an existing network which I just want to modify by adding some extra layers, and then I'm stuck. Any suggestions?
ex: given a network x that has scalar as output, try
NetFlatten[NetChain[{x, Tanh}]]
the output will be a vector of size 1... trying
NetFlatten[NetChain[{x, Tanh}, "Output" -> "Real"]]
Update: still stuck on this one, it's really frustrating. An even simpler version of the same problem: given a chain x
that outputs scalar, try
NetChain[Normal[x]]
the result outputs a vector of size 1.
NetChain[{50,Ramp,50,Ramp,50,Ramp,1,Tanh}]
but to get it to have scalar output the only way I found is to train it (withNetTrain
) with scalar expected output. $\endgroup$