The program always alerts the error of using trainNetwork (line 184) subscript out of range or 184 iThrowCNNException(e). Can anyone help?
2 ビュー (過去 30 日間)
古いコメントを表示
xtrain = mat2cell(data, [3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3]);
for i = 1:25
xtrain{i}= xtrain{i}(~isnan(xtrain{i}));
xtrain{i} = reshape(xtrain{i},3,[]);
end
%%
data01 =readcell("数据提取.xlsx",Sheet="label02",NumHeaderLines=1);
data01 = data01';
ytrain =mat2cell(data01 ,[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]);
for i = 1:25
ytrain{i} = string(ytrain{i}) ;
ytrain{i} = rmmissing(ytrain{i});
ytrain{i} = categorical(ytrain{i});
end
%%
numFeatures = 3;
numHiddenUnits = 200;
numClasses = 6;
layers = [ ...
sequenceInputLayer(numFeatures)
lstmLayer(numHiddenUnits,'OutputMode','sequence')
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
%
options = trainingOptions('adam', ...
'MaxEpochs',60, ...
'GradientThreshold',2, ...
'Verbose',0, ...
'Plots','training-progress');
%%
net = trainNetwork(xtrain,ytrain,layers,options);
0 件のコメント
回答 (1 件)
Aneela
2024 年 10 月 8 日
The error you are encountering with the “trainNetwork” function is due to the mismatch between the dimensions of “xTrain” and “yTrain”.
Ensure that both “xTrain” and “yTrain” have same number of sequences before and after preprocessing:
disp(length(xTrain));
disp(length(yTrain));
For more information on “trainNetwork”, refer to the following MathWorks documentation: https://www.mathworks.com/help/deeplearning/ref/trainnetwork.html
Also, it is recommended to use “trainnet” instead of “trainNetwork”: https://www.mathworks.com/help/deeplearning/ref/trainnet.html
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Deep Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!