Message Boards Message Boards

Plot the round loss,batch loss and use other properties of nettrain?

Posted 6 years ago

I am using the NetTrain and i want to plot the graphs that i see during the training that takes place and also the batch loss and round loss.

I saw the documentation and found something about NetTrain[net, data, prop] where prop has various options but when i try to use them the training just doesnt happen but does not give any error.

Please help.

POSTED BY: Pushkar D
4 Replies

Pushkar D, something below will work:

{batchloss, roundloss, trained} = 
 NetTrain[LinearLayer[], {1 -> 1.9, 2 -> 4.1, 3 -> 6.0, 4 -> 8.1}, 
 {"BatchLossList", "RoundLossList", "TrainedNet"}]

This also work:

trained2 =
  NetTrain[LinearLayer[], {1 -> 1.9, 2 -> 4.1, 3 -> 6.0, 4 -> 8.1},
   All];
batchloss = trained2["BatchLossList"]
roundloss = trained2["RoundLossList"]
POSTED BY: Kotaro Okazaki
Posted 6 years ago

@Kotaro Okazaki I have been trying to do something similar and ran into a different problem:

trainedNet = 
  NetTrain[vggNet2, trainingData, ValidationSet -> testingData, All, 
   MaxTrainingRounds -> maxTrainingRounds, BatchSize -> batchSize, 
   Method -> {optimizer}];

batchloss = trainedNet["BatchLossList"]
roundloss = trainedNet["RoundLossList"]

The problem i am facing is :

NetTrain[NetChain[Input port:   image
Output port:    class
Number of layers:   47    ],
{ here it gives list of all the input images i have given}, All, MaxTrainingRounds -> 1, BatchSize -> 4, 
      Method -> {"ADAM"}]["BatchLossList"]

It does the same with RoundLossList as well, can you please suggest what i am doing wrong? The net is not getting trained.

POSTED BY: Ashish Sharma

Ashish, I do not know what is happening to you. The following code that looks like your code seems to work.

resource = ResourceObject["MNIST"];
trainingData = 
  RandomSample[ResourceData[resource, "TrainingData"], 100];
lenet = NetChain[{
   ConvolutionLayer[20, 5], Ramp, PoolingLayer[2, 2],
   ConvolutionLayer[50, 5], Ramp, PoolingLayer[2, 2],
   FlattenLayer[], 500, Ramp, 10, SoftmaxLayer[]},
  "Output" -> NetDecoder[{"Class", Range[0, 9]}],
  "Input" -> NetEncoder[{"Image", {28, 28}, "Grayscale"}]
  ]
NetTrain[lenet, trainingData, All, MaxTrainingRounds -> 1, 
  BatchSize -> 4, Method -> {"ADAM"}]["BatchLossList"]

enter image description here enter image description here

POSTED BY: Kotaro Okazaki
Posted 6 years ago

@Kotaro Okazaki I apologize, looks like the mistake was at my side. It got solved when i implemented the way you suggested.

Thank you for your help.

POSTED BY: Ashish Sharma
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract