Invalid training data. Labels must not contain undefined values.

1 view (last 30 days)
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 Comments
ASHLY JOSE
ASHLY JOSE on 10 May 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
Walter Roberson on 10 May 2023
Some of entries in the data file were empty instead of having a valid class

Sign in to comment.

Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!