Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Neural Networks in MATLAB, initial weights [closed]

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

like image 657
user999507 Avatar asked Jan 18 '23 12:01

user999507


1 Answers

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.

like image 154
Amro Avatar answered Feb 01 '23 01:02

Amro