I made Neural Network in MATLAB with newff(...). When you train it with the same inputs and outputs, the training results are different on different runs. I understand that it is happening because the weights are different for each time I run it. My question is how to make initial weights to be the same each time I train my NN so I can get the same results? Also, is it possible to save some weights from training No1 and latter use it for training No2, and how?
Tnx
To generate reproducible results, you need to manually set the random number generator to the same seed/state at the beginning of the code. This can be done in a number of ways (depending on what version of MATLAB you have):
The old style:
rand('twister',1234)
The updated style:
RandStream.setGlobalStream( RandStream('mt19937ar','Seed',1234) );
A new function was introduced in R2011a that simplifies the last call:
rng(1234,'twister')
The latter syntax is the recommended approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With