How can I calculate or monitor the training of a neural network in pybrain?
Asked Answered
S

2

9

I have a neural network n pybrain,with two inputs,a hidden layer and a output layer.I use the following to train:

trainer = BackpropTrainer(net,ds)
trainer.trainUntilConvergence()

net is the neural network and ds is the train data.

My question is if and how I can calculate the time needed to complete the training or how can I monitor the progress of the training.Thanks.

Sihunn answered 4/2, 2012 at 0:54 Comment(0)
K
10

You could always subclass BackpropTrainer (source code here) and override trainUntilConvergence if using maxEpochs , track the percentage of completeness using the ratio between epochs and epochs.

If not using maxEpochs you could always make an educated guess of the number of epochs remaining based on the average rate of change in the validationerrors and the size of continueEpochs. Or merely just examine the rate of change in validationerrors. If you wanted to map epochs to time you would have to profile the time of each epoch and store them.

Knp answered 18/2, 2012 at 22:24 Comment(1)
Ideally you would want to use trainEpochs() instead of modifying trainUntilConvergence(). Train for X number of epochs, check result, Train x number of epochs. Repeat until convergence or max epochs.Redbird
E
2

Nothing to add to the previous comment except for the code I use for it:

maxepochs=20
results=[]
for i in range(len(maxepochs)):
    aux = trainer.train()
    results.extend(aux)
    plt.figure()
    plt.scatter(range(len(results[0])),results[0])
    plt.draw()

You would get a new plot at every cycle. Is not very nice, but it works for me.

Hope I'd help you

Erma answered 18/5, 2015 at 13:37 Comment(1)
maxepochs is an int. Does not have len property. Did you mean results.append(aux) ?Destine

© 2022 - 2024 — McMap. All rights reserved.