Clear Filters
Clear Filters

How can I maintain similar time step for Feedback and inputs while using preparats function in NARX Model?

6 views (last 30 days)
I am trying to run the following code
net = narxnet(1:2,1:2,13,'open','trainlm');
u = con2seq(train_in);
v = con2seq(train_tr);
[xs, xi, ai, ts] = preparets(net,u,{},v);
net.trainParam.max_fail = 1000;
Error Massage: Error using preparets (line 105)
Feedback and inputs have different numbers of timesteps.
how can i fixed it?
thanks in advance

Answers (1)

Aditya
Aditya on 6 Sep 2023
Hey Rubel
I understand that you are facing an error in using perparets.
The error message you encountered, "Feedback and inputs have different numbers of timesteps," suggests that the input and target sequences you provided to the `preparets` function have different lengths. To fix this error, you need to ensure that the input and target sequences have the same number of timesteps.
Here are a few possible solutions:
1. Check the lengths of your `train_in` and `train_tr` sequences. Make sure that they have the same number of timesteps. If they don't, you need to align or truncate the sequences to have the same length.
2. If your sequences have varying lengths, you can use padding or interpolation techniques to make them the same length. Padding involves adding zeros or a specific value to the shorter sequence to match the length of the longer sequence. Interpolation techniques can be used to estimate missing values or interpolate the shorter sequence to match the length of the longer sequence.
3. If your input and target sequences have different lengths due to a specific reason (e.g., different sampling rates or time delays), you may need to reconsider the network architecture or adjust the problem formulation to handle such variations.
Once you have ensured that the input and target sequences have the same number of timesteps, you can proceed with the `preparets` function. It's worth noting that the `preparets` function is specific to the Neural Network Toolbox in MATLAB, so make sure you are using the correct version and have the necessary toolbox installed.
By addressing the issue of different timesteps between the input and target sequences, you should be able to resolve the error and continue with your neural network training.
Here is the documentation link for your reference:

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!