MATLAB: How to find the value used to seed neural networks in Matlab

neural networkrandom number generator

Hi,
I am using this in Matlab to build and train a neural network, network = fitnet(15); [network, model] = train(network, trainData, trainLabels);
The training results are different each time I run the code. I know that this is due to the random generation of initial weights and biases seeded by some value.
Is it possible for me to know this seed value? If yes, then how can I get it?

Best Answer

Store the state of the random number generator using rng BEFORE you create or initialize your network. Then you can restore the state (again using rng) before the next time you create or initialize a network.