I recently downloaded Mathematica 12, and I'm experiencing a curious failure in neural networks that had earlier worked. This failure I will demonstrate with the NN in "Classifying Data with Neural Networks—Wolfram Language Documentation" https://reference.wolfram.com/language/tutorial/NeuralNetworksClassification.html#280210622
Everything in that page works until this line:
results = NetTrain[net, trainingData, All]
It gives $Failed with this message:
NetTrain::encgenfail2: Could not encode one or more inputs for port "Output": supplied data was a length-64 vector of real numbers, but expected a class. The invalid inputs had indices {504,841,210,1645,1285,165,956,691,940,613,1426,297,1560,754,650,1725,1662,44,831,1160,1262,1289,1060,886,1147,1578,1342,424,1176,749,1664,1030,211,1011,121,475,237,1120,79,1399,287,1791,293,214,271,222,761,1511,960,1154,<<14>>}.
What is going wrong? A very similar NN worked in version 11.
ETA: detailed version info:
Mma 12.0.0.0 for Mac OS X x86 (64-bit) running on macOS Mojave 10.14.4
The complete code, from that link:
makeCluster[class_, \[Mu]_, \[Rho]_] :=
RandomVariate[
MultinormalDistribution[\[Mu], {{1, 2 \[Rho]}, {2 \[Rho], 4}}],
600] -> class; clusters =
makeCluster @@@ {{Red, {1.5, 1.5}, -.2}, {Green, {-1.5,
1}, .1}, {Blue, {0, -2.5}, .8}}; trainingData = Flatten[Thread /@ clusters]
net = NetChain[{LinearLayer[30], ElementwiseLayer[Ramp],
LinearLayer[3], SoftmaxLayer[]}, "Input" -> {2},
"Output" -> NetDecoder[{"Class", {Red, Green, Blue}}]]
results = NetTrain[net, trainingData, All]
Comments
Post a Comment