MATLAB Answers

Number of epoch equals number of loop iterations

16 views (last 30 days)
Salman Habib
Salman Habib on 8 Apr 2017
Answered: Greg Heath on 25 Apr 2017
I am trying to train a neural network using for loop, 1 epoch at at time, and I want matlab to continue training with the weights and biases from the previous training. Is there any way to save the weights during the current iteration of the loop, and use them to initialize the neural network weights and biases in the next loop iteration ? (that is, I want the number of epochs to be the same as the number of iterations of the for loop ,say N, and call the training function N times)
Thank you in advance.

Answers (2)

Chaitral Date
Chaitral Date on 24 Apr 2017
I am not sure which function you are using to train the neural network. But below are some of the possible options that you can follow,
1) To save the weights and biases of the current iteration and to use them in future, you can always use functions "save" and "load".
2) You can also define the weights and biases as persistent variables and update them in every iteration.
Also, to get the weights and biases of a given network, you can use function "getwb".
I hope this helps!

Greg Heath
Greg Heath on 25 Apr 2017
It doesn't make any sense to record every weight after every epoch.
The net will automatically carry the last updated weights to the start of pthe next iteration.
Therefore, all you have to do is to assign 1 (unity) to the net property that defines the number of epochs to train.
Hope this helps.
Thank you for formally accepting my answer
Greg

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!