Invalid training data. Labels must not contain undefined values.
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 13 Feb. 2020
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
am 13 Feb. 2020
ASHLY JOSE
am 10 Mai 2023
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
am 10 Mai 2023
Some of entries in the data file were empty instead of having a valid class
Antworten (0)
Kategorien
Mehr zu Parallel and Cloud finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!