I’m trying to apply the Alexnet transfer learning example but it’s not working with my dataset
I’m trying to follow the steps in this example Transfer learning using AlexNet using my set of images but it’s giving me this error
Error using trainNetwork (line 154)
augmentedImageSource cannot form MiniBatches of data because input image sizes differ in 3rd dimension. Consider
using 'ColorPreprocessing' option to ensure all augmented images have same number of channels.
Error in TrainAlexnet (line 42)
netTransfer = trainNetwork(augimdsTrain,layers,options);
Caused by:
Error using augmentedImageDatastore/applyAugmentationPipeline (line 335)
augmentedImageSource cannot form MiniBatches of data because input image sizes differ in 3rd dimension.
Consider using 'ColorPreprocessing' option to ensure all augmented images have same number of channels.
I even resized all images to [227 227 3], same error. I also had the same problem with GoogLeNet
ANSWER
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
imresize does not accept [227 227 3] as a parameter. You would have used imresize with [227 227] as a parameter. However, imresize does not change the number of color channels.
In short: some of your files are not RGB images. They are one of:
- binary images (PNG) (TIFF)
- grayscale images (GIF) (PNG) (TIFF) (JPG but quite rare)
- pseudocolor images (GIF) (PNG) (TIFF)
- CMYK images (TIFF)
- RGBA images (TIFF) (possible with PNG even if not officially supported; PNG prefers RGB+A)
JPEG 2000 should also be in that table somewhere, but I do not remember exactly what it supports.
Possibly you have some JPEG that you are thinking are grayscale. Grayscale JPEG are very very uncommon: I have only encountered one in about 20 years that was not a test image to prove that it could be done. Nearly all JPEG images that appear to be grayscale are instead RGB images.
SEE COMPLETE ANSWER CLICK THE LINK