The program always alerts the error of using trainNetwork (line 184) subscript out of range or 184 iThrowCNNException(e). Can anyone help?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Aneela
le 8 Oct 2024
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 commentaires
Voir également
Catégories
En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!