Message Boards Message Boards


Find accuracy for a neural network?

Posted 2 months ago
2 Replies
0 Total Likes

Hallo, I defined the following network

net = NetChain[Flatten@Table[{LinearLayer[50], ElementwiseLayer[Tanh]}, 3]]
net = NetJoin[net, {LinearLayer[9]}]

the input are arrays of Length 10 and the outputs are arrays of length 9. And I trained it successfully as:

trainednet = NetTrain[net, train, ValidationSet -> test, MaxTrainingRounds -> 500]

I'm trying to find the accuracy of the net so I used the following:

res = NetTrain[net, train, All, TrainingProgressMeasurements -> {"Accuracy"}]

But I got the following error message:

NetTrain::nometriclayer: One or more measurements require a CrossEntropyLossLayer to be present in the training net, but there are none.

I tried to add CrossEntropyLossLayer, but Smth is going wrong. Can you recommend how I got the accuracy of such net. Thanx in advance.

2 Replies
Posted 2 months ago

Hi Maha,

You need to run the trained net on test data to assess the accuracy and other metrics. Split your data into e.g. 80% train, 10% validation and 10% test. Use the train and validation data during training and then run NetMeasurements on the test data. Check the documentation for examples.

Still the same problem:

In[122]:= NetMeasurements[net, testdata, "Accuracy"]

Out[122]= $Failed
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract