How can I save the parameters in neural networks at the end of every period t-1 and use them to reinitialize train from that point at time t?

3 views (last 30 days)
I am using Matlab and I try to train a neural network. Due to the big number of observations I need to reduce the computational time. Hence, I would like my network to save the parameters computed for time t-1 and use these as initial point for time t (instead of iterating say 1000 times for the solution, to iterate 6-10). The mocking code I prepared, without including the for loop, is the following, it works but without doing what I ask to do
clear;
x = randn(1,100);
y = x.^2;
HU = 2;
nets = trainnet(HU)
nets = train(nets,x,y)
net1 = configure(nets,x,y);
net1.IW = nets.IW;
net1.LW = nets.LW;
net1.b = nets.b;
net1 = trainnet(HU)
net1 = train(net1,x,y)
function net = trainnet(HU)
trainFcn = 'trainlm';
hiddenLayerSize = HU;
net = fitnet(hiddenLayerSize,trainFcn);
I would really appreciate any help. Thanks in advance.

Answers (0)

Community Treasure Hunt

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

Start Hunting!