Error using preparets with narxnet

9 次查看(过去 30 天)
I'm trying to use a closed loop narxnet for some time series prediction, but I'm having trouble getting past the preparets step.
My network is 2 inputs, 1 feedback target
view(net) shows this is correct
However this code throws an error. As far as I can tell, my input/target cell arrays are the size they should be to match the configured network.
% dummy data
X = rand(2,100);
T = rand(1,100);
% set up network
net = narxnet(1:2,1:2,5);
net = closeloop(net);
net = configure(net,X,T);
% Net shows 2 inputs 1 output
view(net)
% convert to cells
X = num2cell(X); % X is 2x100
T = num2cell(T); % T is 1x100
% Here's the problem
[Xs,Xi,Ai,Ts] = preparets(net,X,{},T);
Thanks in advance

采纳的回答

Chris Wolf
Chris Wolf 2020-3-20
Nm, I got it myself. For those with similar problems, you need to use con2seq to turn your input/output matrices into input/output sequential vectors. No idea where you are supposed to read about this step in the documentation, and it seems like something that can be easily handled behind the scenes without having to confuse users.
These days I work with a lot of ML and AI experts, and they laugh at me for insisting on using matlab for everything. I'm starting to think they have a point.
% Instead of:
% X = num2cell(X); % X is 2x100
% T = num2cell(T); % T is 1x100
% Use:
X = con2seq(X);
T = con2seq(T);
  1 个评论
Muhammad Waqar
Muhammad Waqar 2021-9-4
My training is perfect while using con2seq() function. But when i am testing my data for 8 inputs and 8 outputs, its give me an error of
Error using network/sim (line 270)
Number of inputs does not match net.numInputs.
Error in narxnetFcn (line 139)
load_forecast = sim(net,testX1);
Answer of net.numInputs =2 in my case while i have 8 inputs data. Then I have manually changed net.numInputs to 8 but no effect on error.
Now as my input data is changed to cell vector, my network is trained for that data. I need to solve this problem for testing my network. If there is any solution, kindly let me know.
thanks

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by