NARX Input Size Problem

4 views (last 30 days)
osman alper altun
osman alper altun on 25 Feb 2023
Answered: Shubham on 5 Apr 2023
Hello,
I've already trained network using NARX. Right now I'm dealing with test the network with new dataset. Here is my code:
[p1,Pi1,Ai1,t1] = preparets(narx_net,input_u,{},output_y);
yp1 = narx_net(p1,Pi1,Ai1);
Once it runs, it generates below error:
Error using network/sim
Input data sizes do not match net.inputs{1}.size.
Error in indexing (line 15)
otherwise, v = sim(vin,subs{:});
Error in v2_test_NARX (line 71)
yp1 = narx_net(p1,Pi1,Ai1);
I checked the sizes of input and output but they are same size.
size_in = size(input_u)
size_out = size(output_y)
---------------------------------
size_in =
1 39060
size_out =
1 39060
I don't understand what's the issue and I'm using the same strategy as training part but I couldn't see any difference for the using of preparets.
Please give any advice to solve this issue.
  2 Comments
Amanjit Dulai
Amanjit Dulai on 27 Feb 2023
It's a bit tricky to debug this issue without the full code.
  • What is the size of the data you used for training?
  • Is the training and prediction data formatted as a cell array?
  • What command are you using to create narx_net?

Sign in to comment.

Answers (1)

Shubham
Shubham on 5 Apr 2023
Hi osman,
Based on the error message, it seems that the size of the input data passed to the network does not match the expected size of the network's input layer. Even though you have checked that the sizes of the input and output data are the same, there might be a problem with the format of the input data that is causing the error.
One possible cause of the error is that the input data has the wrong dimensions. The preparets function expects a cell array of time sequences, where each time sequence is a numeric matrix with the same number of rows and the same number of columns as the input data. Therefore, you may need to ensure that the input data is formatted correctly before passing it to the preparets function. Here is an example of how you can format your input data:
input_seq = num2cell(input_u,1);
output_seq = num2cell(output_y,1);
[p1,Pi1,Ai1,t1] = preparets(narx_net,input_seq,{},output_seq);
Here, num2cell is used to convert the input and output data into cell arrays of numeric sequences, where each sequence has only one time step.
Another possible cause of the error is that the network's input size is not set correctly. You can check the size of the network's input layer using the following code:
input_size = narx_net.inputs{1}.size;
Make sure that the size of the input data matches the size of the input layer of the network. If not, you may need to adjust the input size of the network to match the size of the input data.
I hope this helps!

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!