Error using trainNetwork (line 184) Invalid training data. Predictors must be in a N-by-1 cell array of sequences, where N is the number of sequences.
1 次查看(过去 30 天)
显示 更早的评论
I tried to make a sequential classifier using using a LSTM but I got an error saying:
"Error using trainNetwork (line 184) Invalid training data. Predictors must be in a N-by-1 cell array of sequences, where N is the number of sequences. All sequences must have the same feature dimension and at least one time step."
below I included the code and images.
load Data1
load Data2
load Data1_ds1
load Data2_ds1
XTrain = {Data1;Data2;Data1_ds1;Data2_ds1}
XValidation = {Data1_ds1;Data2_ds1}
TTrain = [1;1;2;2]
TTrain = categorical(TTrain)
TValidation = [1;2]
TValidation = categorical(TValidation)
XTrain(1:2)
classes = categories(TTrain)
numClasses = numel(classes)
%numClasses = 23
filterSize = 3;
numFilters = 32;
numFeatures = 2;
layers = [ ...
sequenceInputLayer(numFeatures)
bilstmLayer(100,'OutputMode','sequence')
fullyConnectedLayer(2)
softmaxLayer
classificationLayer
]
miniBatchSize = 27;
% options = trainingOptions("adam", ...
% MiniBatchSize=miniBatchSize, ...
% MaxEpochs=10, ...
% SequencePaddingDirection="left", ...
% ValidationData={XValidation,TValidation}, ...
% Plots="training-progress", ...
% Verbose=0);
options = trainingOptions('adam', ...
'MaxEpochs',10, ...
'MiniBatchSize', miniBatchSize, ...
'InitialLearnRate', 0.01, ...
'SequenceLength', 100, ...
'GradientThreshold', 1, ...
'ExecutionEnvironment',"auto",...
'plots','training-progress', ...
'Verbose',false);
net = trainNetwork(XTrain,TTrain,layers,options);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/854245/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/854250/image.png)
0 个评论
回答(1 个)
yanqi liu
2022-1-8
yes,sir,may be modify
XTrain = {Data1;Data2;Data1_ds1;Data2_ds1}
XValidation = {Data1_ds1;Data2_ds1}
to
XTrain = [Data1;Data2;Data1_ds1;Data2_ds1]
XValidation = [Data1_ds1;Data2_ds1]
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!