Invalid training data. Labels must not contain undefined values.
이전 댓글 표시
Trying to train an LSTM with 3 classes, and 11 features. trainX is a 507*1 cell array of 11*n double matricies, and trainY is a 507*1 cell array of 1*n categorical vectors.
Here's my code
optsX = detectImportOptions('Ordered Name.csv');
optsX.SelectedVariableNames = [18,25,26,32,33,34,35,36,78,80,81];
holdX = readmatrix('Ordered Name.csv',optsX);
optsY = detectImportOptions('Ordered Name.csv');
optsY.SelectedVariableNames = 1;
holdY = readmatrix('Ordered Name.csv',optsY);
types = {'A','B','C'};
top = 1;
previous = 1;
counter = 1;
trainX = {};
trainY = {};
for i = 1:size(holdX,1)
if(previous - holdX(i,9) > 1)
trainX{counter,1} = holdX(top:i-1,:)';
trainY{counter,1} = categorical(holdY(top:i-1,:)',types,'Ordinal',true);
top = i;
counter = counter + 1;
end
previous = holdX(i,9);
end
trainX{counter,1} = holdX(top:i-1,:)';
trainY{counter,1} = categorical(holdY(top:i-1,:)',types,'Ordinal',true);
numFeatures = 11;
numHiddenUnits = 200;
numClasses = 3;
layers = [ ...
sequenceInputLayer(numFeatures)
lstmLayer(numHiddenUnits,'OutputMode','sequence')
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
options = trainingOptions('adam', ...
'MaxEpochs',10, ...
'GradientThreshold',2, ...
'Verbose',0, ...
'Plots','training-progress');
net = trainNetwork(trainX,trainY,layers,options);
I keep getting the error: Invalid training data. Labels must not contain undefined values. I was unable to find any sort of question that had this error answered, hoping for someone pointing out something stupid I missed
Edit: Names modified to be more general
Edit 2: I'm a big dumb who didn't notice that some of the labels listed in his data were null. Leaving this up for someone else who encounters this to check their data.
댓글 수: 4
Walter Roberson
2020년 2월 13일
trainY{counter,1} = categorical(holdY(top:i-1,:)',types,'Ordinal',true);
You are building a categorical. If any of the values selected out of holdY are not in the list indicated by types, then you would get an <undefined> in the categorical result.
NICHOLAS WILKE
2020년 2월 13일
ASHLY JOSE
2023년 5월 10일
Hi, Iam facing the same problem, but iam dealing with images. what do you mean when you say 'some of the labels were null'?
Thank you
Walter Roberson
2023년 5월 10일
Some of entries in the data file were empty instead of having a valid class
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Parallel and Cloud에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!