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?

 Respuesta aceptada

Sean de Wolski
Sean de Wolski el 24 de Oct. de 2012

0 votos

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 comentarios

Unnikrishnan PC
Unnikrishnan PC el 25 de Oct. de 2012
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.
Greg Heath
Greg Heath el 25 de Oct. de 2012
%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
Greg Heath
Greg Heath el 25 de Oct. de 2012
Why did you put a previously asked question in this post as a comment?
See the other post for my answer.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by