Greg is right, the function to get weights outside of a training function is getwb.
Within a training function it is slightly different. In recent versions of the Neural Network Toolbox, each training function has a trainingIteration helper function. (I.e. edit trainlm for an example.) And within a training function the most reliable way to get weights is calcLib.getwb(calcNet). (Also, see trainlm code for example of this being used.)
So you might insert the following code snippet at the end of trainingIteration in trainlm to get and save a record of the weights in a workspace variable "weightRecord".
try
wr = evalin('base','weightRecord');
catch
wr = {};
end
wr{end+1} = calcLib.getwb(calcNet);
assignin('base','weightRecord',wr);
If you then train with TRAINLM you can get the weight record in the base workspace:
>> [x,t] = house_dataset;
>> net = feedforwardnet(10,'trainlm');
>> net = train(net,x,t);
>> weightRecord
weightRecord =
Columns 1 through 4
[151x1 double] [151x1 double] [151x1 double] ...
1 Comment
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/230414-how-can-i-extract-the-values-of-weights-and-biases-after-each-training-epoch#comment_299054
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/230414-how-can-i-extract-the-values-of-weights-and-biases-after-each-training-epoch#comment_299054
Sign in to comment.