MATLAB Answers


How to give new input to trained network and getting output using neural network toolbox

Asked by ABHAY SONI on 22 Aug 2013
Latest activity Answered by Greg Heath
on 13 Nov 2017
Hello Friends,
I am using neural network toolbox. I have trained the net using input matrix of 5 X 48 and output matrix of 2 X 48. The network is saved by name Abhay. Now I want to use this network using a 5 X 1 input matrix and the corresponding output should be a 2 X 1 matrix as it is trained. I used, y = sim(Abhay,r) % r is the 5 X 1 input matrix. The result of this command should be a 2 X 1 but I am getting error regarding the size of input. so please if anyone can explain the problem and remedy.


function net = Abhay(inputs,targets) %CREATE_FIT_NET Creates and trains a fitting neural network. % % NET = CREATE_FIT_NET(INPUTS,TARGETS) takes these arguments: % INPUTS - RxQ matrix of Q R-element input samples % TARGETS - SxQ matrix of Q S-element associated target samples % arranged as columns, and returns these results: % NET - The trained neural network % % For example, to solve the Simple Fit dataset problem with this function: % % load simplefit_dataset % net = create_fit_net(simplefitInputs,simplefitTargets); % simplefitOutputs = sim(net,simplefitInputs); % % To reproduce the results you obtained in NFTOOL: % % net = create_fit_net(data',data');
% Create Network numHiddenNeurons = 40; % Adjust as desired net = newfit(inputs,targets,numHiddenNeurons); net.divideParam.trainRatio = 70/100; % Adjust as desired net.divideParam.valRatio = 15/100; % Adjust as desired net.divideParam.testRatio = 15/100; % Adjust as desired
% Train and Apply Network [net,tr] = train(net,inputs,targets); outputs = sim(net,inputs);
% Plot plotperf(tr) plotfit(net,inputs,targets) plotregression(targets,outputs)
The error
>> Abhay ??? Input argument "inputs" is undefined.
Error in ==> Abhay at 22 net = newfit(inputs,targets,numHiddenNeurons);
Please format. See the code symbol {}?
I don't understand. You previously mentioned an error regarding size(r) Where is the code relating to that?
Now you have an error because the variable inputs was never defined.
What version are you using?
newfit Create a fitting network.
Obsoleted in R2010b NNET 7.0. Last used in R2010a NNET 6.0.4.
Hope this helps.

Sign in to comment.

1 Answer

Answer by Greg Heath
on 13 Nov 2017

Bottom Line:
You used "inputs" instead of the defined "SimplefitInputs"
Hope this helps.
Thank you for formally accepting my answer
PS: Take the time to FORMAT your questions with the {} operator. THEN your mistakes will become more obvious to us!


Sign in to comment.