"Index in position 2 exceeds array bounds (must not exceed 1)" with machine learning
1 次查看(过去 30 天)
显示 更早的评论
Purpose: I am a beginner of machine learning that seeks to use neural network and large number of predictors to predict values.
Problem: When I attempted to follow the sample from other cases from Matlab answers, the result won't allow me to train the data. Instead, it kept telling me "Index in position 2 exceeds array bounds (must not exceed 1)" with machine learning
Code Used:
%Q and S are imported time series; Q is the predictor variable and S is the targed variable
Sn = (S-min(S))/(max(S)-min(S));%normalizing S, 7670x1 Double
Qn = (Q-min(Q))/(max(Q)-min(Q));%normalizing Q, 7670x1 Double
trainFcn ='trainlm';
%Train my data with Narxnet
hiddenLayerSize = 10
N = 7671
inputDelays = 5
feedbacksDelays = 5
net = narxnet(1:inputDelays, 1:feedbacksDelays,hiddenLayerSize);
[Xs,Xi,Ai,Ts] = preparets(net,Sn,{},Qn);
0 个评论
回答(1 个)
Srivardhan Gadila
2020-7-15
As per my understanding after referring to train - Input Arguments & preparets, I think the network inputs & targets must be a cell array and not matrix in case of time series data. Also the shape of the cell array should be according to the documentation, refer to the example of narxnet to understand the shape of X & T i.e., input & target.
In your above code Sn & Qn are 7670x1 Double, try changing them to cell array of shape 1x7670. The following code might help you:
Sn = num2cell(randn(7670,1)');
Qn = num2cell(randn(7670,1)');
trainFcn ='trainlm';
%Train my data with Narxnet
hiddenLayerSize = 10
N = 7671
inputDelays = 5
feedbacksDelays = 5
% net = narxnet(1:inputDelays, 1:feedbacksDelays,hiddenLayerSize);
net = narxnet(1:5, 1:5,10);
[Xs,Xi,Ai,Ts] = preparets(net,Sn,{},Qn);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!