Neural Network Tool Box

I am working on a classification problem and the codes are written in m files. I am calling net=newff(....) within the m file.Once the network is trained, How to save the net? How to access the net weights?

 采纳的回答

What version are you using? We recommend using feedforwardnet.
If you run the example from the doc for feedforwardnet, you can access the net weights:
net.InputWeights
net.LayerWeights
And it can be saved to a *.mat file the same way you save any variable.

3 个评论

Dear Sean, Thanks for your suggestion. I will explain my problem. My code is given below.
% *******************************************Plant***************************************** s=5000; u = zeros(1, s); y = zeros(1, s); yhat = zeros(1, s);
for k=1:s u(k)= unifrnd(-1,1); if (k==1) y(k)=0; elseif (k==2) y(k)=0.3*y(k-1)+u(k)+0.3*u(k); else y(k)=0.3*y(k-1)+0.6*y(k-2)+u(k)+0.3*u(k); end end % *************************************NN Modelling***************************************** % Creating Neural Net [yn,ys] = mapminmax(y); net = newcf(u,yn,[20 10] ,{'tansig','tansig','purelin'},'trainscg');
% Training Neural Net net.trainParam.lr = 0.05; net.trainParam.lr_inc = 1.05; net.trainParam.lr_dec = 0.7; net.trainParam.hide = 50; net.trainParam.mc = 0.9; net.trainParam.epochs = s; net.trainParam.goal = 1e-5; net.trainParam.max_fail = s; net.trainParam.time = 3*3600; trainInd = 1:1:s; valInd = 2:50:s; testInd = 3:50:s; [trainu,valu,testu] = divideind(u,trainInd,valInd,testInd); [trainy,valy,testy] = divideind(yn,trainInd,valInd,testInd); net = init(net); net = train(net,u,yn);
The actual problem is different. The above program is written in an m-file and takes about 15 minutes to converge. Can you go through the program and tell me if I am correct in programming? I wish to use this net for another set of inputs. For this, I need to access the trained net. How the trained net is saved external to this m file and how to access it? Please help. Thanks in advance.
%What version are you using? We recommend using feedforwardnet.
PATTERNNET is more appropriate for classification
%If you run the example from the doc for feedforwardnet, you can access the net weights:
%net.InputWeights
%net.LayerWeights
No. The correct syntax is
IW = net.IW{:,:}
LW = net.LW{:,:}
b = net.b{:,:}
%And it can be saved to a *.mat file the same way you save any variable.
Correct.
Greg
Why did you put a previously asked question in this post as a comment?
See the other post for my answer.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Deep Learning Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by