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);
댓글 수: 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!