MATLAB Answers

Training Failed - Deep Network designer

9 views (last 30 days)
Shane Philip Abreu
Shane Philip Abreu on 17 Mar 2021
Answered: Srivardhan Gadila on 16 Apr 2021
I have a training error when trying to retrain an AlexNet on my dataset. I can get the data to work when using a small amount such as 10 images but when I try to use approx 500 in each of the 2 classes it states "Training failed. Augnmented Image Datastore cannot form MiniBatches of data because input images differ in 3rd dimension. Consider using 'ColorPreprocessing option to ensure all augmented images have same number of channels"
Can anyone help please?

Answers (1)

Srivardhan Gadila
Srivardhan Gadila on 16 Apr 2021
As the error clearly states, it seems that your data contains a mixture of grayscale and RGB images, use ColorPreprocessing Name-Value pair argument to ensure that all output images have the number of channels required by imageInputLayer of alexnet.
Refer to the description of ColorPreprocessing of AugmentedImageDatastore and Import Data into Deep Network Designer for more information.
Also make sure that all of your images have the size same as alexnet input layer which is
net = alexnet;
inputSize = net.Layers(1).InputSize
inputSize = 1×3
227 227 3
You can set OutputSize of augmentedImageDatastore to [227 227] for this.

Community Treasure Hunt

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

Start Hunting!

Translated by