Usage problem of saved neural network

2 views (last 30 days)
I have used nnstart to predict future values of my time-series data, what is succeded, and I saved the network to .m file, what I can't use for further use for similar data. The automatically generated script works if the final line is outputs = train(net,inputs,targets,inputStates,layerStates); but is not working with the saved net instead of train, even not with the data the saved network trained with. So I tried just simply to replace the
outputs = train(net,inputs,targets,inputStates,layerStates);
to
load('mynet', 'net');
outputs = net(inputs,inputStates,layerStates);
or even
outputs = net(inputs,inputStates,layerStates,targets);
but not works, even not for the same sample data that it used for the train. The code was:
inputSeries = pollutionInputs;
targetSeries = pollutionTargets;
inputDelays = 1:2;
feedbackDelays = 1:2;
hiddenLayerSize = 10;
load('mynet', 'net')
[inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,{},targetSeries);
outputs = net(inputs,inputStates,layerStates);
Where the final line produces the error:
Output argument "data" (and maybe others) not assigned during call to "C:\Program
Files\MATLAB\R2012b\toolbox\nnet\nnet\@network\sim.m>simData".
Error in network/sim (line 291)
[data,err] = simData(net,X,Xi,Ai,T,EW);
Error in network/subsref (line 17)
otherwise, v = sim(vin,subs{:});
Error in narx2 (line 71)
outputs = net(inputs,inputStates,layerStates);
What could cause the problem, and how I could use the saved and loaded network for new datas?
Thank you in advance!

Accepted Answer

Greg Heath
Greg Heath on 7 Oct 2014
1. Check the loaded net to make sure it has all the correct properties
net = net % NO SEMICOLON!
2. Sequentially remove ending semicolons to make sure the command line outputs at each stage makes sense.
Hope this helps.
Thank you for formally accepting my answer
Greg
  1 Comment
Roland Kilik
Roland Kilik on 7 Oct 2014
Starting from your advice (however I already examined the command line output of net before) it seems to work. At least, net = net produced only "[1x1 network]", but net=load('mynet', '-mat') netin=net.mynet seems to work, as it displays all the struct of the newrok
Thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Sequence and Numeric Feature Data Workflows 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!