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 commentaires

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.
Yep, see my Edit 2. That's exactly what happened.
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
Some of entries in the data file were empty instead of having a valid class

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange

Produits

Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by