Can I train my Narxnet with the different Dimensions size data inside cell arrays?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have 3 Different data set with different dimension. For example Data1 size - (15440x4 double), Data2-(2131x4 double), Data3-(14319x4 double). I have use IDdata object and merge IDdata object to combine 3 data set as a Train_ID. I am extracting the Input data and Output data using this from Train_ID. I have 3 Input and 1 output to train my model.
X_Train = Train_ID.u;
X_Train size (1x3 cell) as i mention with different dimension inside as a (15440x3 double 2131x3 double 14319x3 double)
Y_Train = Train_ID.y;
Y_Train size (1x3 cell) as i mention with different dimension inside as a (15440x1 double 2131x1 double 14319x1 double)
I want to train my network using X_Train and Y_Train for my NarxModel.
trainFcn = 'trainbr'
inputDelays = 1:2;
feedbackDelays = 1:2;
hiddenLayerSize = 5;
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
[x,xi,ai,t] = preparets(net,X_Train,{},Y_Train);
It is showing error in preparets function as follow:
Inputs{1,2} and Inputs{1,1} have different numbers of rows.
How can i train my model with different dimention data as a input ?
If this approch is not correct. i would be also happy to get any other way and suggestion.
댓글 수: 0
채택된 답변
Neha
2024년 4월 10일
Hi Hemant,
I understand that you want to train a NARX network with data of different dimensions.
The error you're encountering with the 'preparets' function is due to the fact that 'preparets' expects the input and target data to have the same sequence length when they are presented as cell arrays. Each cell in the input and target arrays should correspond to a separate sequence (or time series), but all sequences within each array must have the same length. This is not the case with your data, as you have sequences of different lengths.
Instead of trying to train on all data at once, you can loop through each sequence, prepare it using 'preparets', and then perform training on that sequence. This method allows you to accommodate the varying lengths of your sequences by preparing and training them one at a time. Please refer to the following code snippet to implement this approach:
for i = 1:length(X_Train)
% Convert data format for preparets
inputs = con2seq(X_Train{i}');
targets = con2seq(Y_Train{i}');
% Prepare the data for the i-th sequence
[x, xi, ai, t] = preparets(net, inputs, {}, targets);
[net, tr] = train(net, x, t, xi, ai);
end
You can refer to the following documentation link for more information on the 'con2seq' function used in the above code snippet:
Hope this helps!
추가 답변 (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!