how neural network outputs are kept constant for each time running the program

5 views (last 30 days)
I used to traingdm algorithm and whenever restart my computer all outputs are changes. Because weights are different. How can I save idealized weights ?

Accepted Answer

Greg Heath
Greg Heath on 30 May 2013
Edited: Greg Heath on 30 May 2013
Random weight initialization and trn/val/tst data division are defaults.
If you wish to duplicate a design you have to reset the state of the RNG. I always use rng(0) before designing the first of multiple designs in a double-loop design
rng(0)
for h = 1:numH % Loop over number of hidden nodes
for n = 1:Ntrials % Loop over number of weight initializations
s(n,h) = rng % save the initial RNG state
net = ...
......
end
end
If the best design occurs for h= Hb, n=Nb it can be recreated via
h = Hb
n = Nb
rng(s(h,n))
net = ...
If you wish to reuse a design, save the net
net1 =net;
save net1;
Then,later
load net1
net = net1
Finally, if you just want to save the weights
wb(h,n) = getwb(net).
NOTE: THE MULTIPLE INPUT COMMANDS IN HELP GETWB AND DOC GETWB ARE ERRONEOUS
Then later you can reconstruct the net via
set(net,wb)
Hope this helps.
Thank you for formally accepting my answer
Greg

More Answers (0)

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!