MATLAB Answers


How to use predict(net,X) with Sequence data or data which have single dimensional input?

Asked by poonam
on 11 Jan 2019
Latest activity Commented on by Greg Heath
on 23 Jan 2019
I have trained the model on input having
size(input) = [1 78852] double
and output of
size(Output) = [1 78852].
The model is trained using command
net = layrecnet(1:2,[20 20],'trainlm');.
I want to use the predict(net, X) but it is giving me error
Error using predict (line 84)
No valid system or dataset was specified.
As my input is single dimentional vector. How to use this predict function in my prgoram?


Sign in to comment.

1 Answer

Answer by Greg Heath
on 11 Jan 2019

  1. How do you expect us to help when you do not show us your code ???
  2. Just the fact that the error involves "predict" and you show no such code is more than enough for a bald man to scratch his head.
  3. Please see the HELP and DOC files before posting a question.


I am using the same example available on matlab documentation page
%%For training
net = layrecnet(1:2,10);
[Xs,Xi,Ai,Ts] = preparets(net,X,T);
net = train(net,Xs,Ts,Xi,Ai);
Y = net(Xs,Xi,Ai);
perf = perform(net,Y,Ts)
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
% Customize plot parameters at: net.plotParam
net.plotFcns = {'plotperform','plottrainstate','plotresponse', 'ploterrcorr', 'plotinerrcorr'};
Now for validation i am validating my model using command below..
Y_val = net(Input_validation_data.');
perf = perform(net,Y_val(1:5000), output_val_data(1:5000));
But It is not even giving the close prediction to my actual output.
So I want to use the predict() function like this command below.
YPred = predict(net,[Input_validation_data(1:10), output_val_data(1:10)] );
Just to share: While training predicted output and actual ouput are perfectly overlaping in plots. But in validating time predicted output only resembles the input data with some shift on x axis. For that reason i want to test my model using predict function.
From help and Doc I was on conclusion that my input is single dimentional vector and in predict() function need the matrix of D-by-S matrix if data is sequential. So, I have tried the alternate way of argument in the funtion. But gettting the same resulted error.
YPred = predict(net,[Input_validation_data(1:10), 11] );
You are not using the MATLAB VERSION of the definition validation.
See the Matlab definitions of train, val and test.

Sign in to comment.