Getting error in training residual network on CIFAR100 data

3 views (last 30 days)
Hi everyone. I followed example from https://www.mathworks.com/help/deeplearning/ug/train-residual-network-for-image-classification.html to train residual network on CIFAR100 dataset. But I keep getting this error:
Error using trainNetwork (line 184)
Invalid validation data. Labels must not contain undefined values.
Error in Residual_Network_cifar100 (line 154)
trainedNet = trainNetwork(augimdsTrain,lgraph,options);
When I check the content of YValidation, it contain list of categorical labels like this:
As you can see from the attached image, there is undefined categorical label, which I believe it caused the error, but I do not know how to fix it. Please anyone help me. Thanks in advance.

Answers (1)

Jayanti
Jayanti on 4 Apr 2025
Hi suzwani,
The error is due to presence of undefined values in the labels. Find undefined values in your data using “isundefined” function.
undefinedLabels = isundefined(YValidation);
“isundefined” function returns a logical array that indicates which elements are undefined values. You can remove any samples with undefined labels from the validation set using the logical array.
For more information refer to the below documentation link on “isundefined”:

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!