"The input images for activations must be of size equal to or greater than [28 28 1]." when using the activations method for CNN?

3 ビュー (過去 30 日間)
My code is:
net = trainNetwork(imdsTrain,layers, options);
imageSize = net.Layers(1).InputSize;
augmentedTrainingSet = augmentedImageDatastore(imageSize, imdsTrain, 'ColorPreprocessing', 'gray2rgb');
augmentedTestSet = augmentedImageDatastore(imageSize, imdsValidation, 'ColorPreprocessing', 'gray2rgb');
featureLayer = 'fc';
trainingFeatures = activations(net, augmentedTrainingSet, featureLayer);
And I take an error as "The input images for activations must be of size equal to or greater than [28 28 1]."
Why I'm taking this error, how can I fix it?
I would be glad if you answer

回答 (2 件)

Sai Bhargav Avula
Sai Bhargav Avula 2020 年 4 月 9 日
編集済み: Sai Bhargav Avula 2020 年 4 月 9 日
Hi,
To the best of my knowledge the issue is because of 'ColorPreprocessing'. It is generally used when you have a mix of gray scale and color images(specifically RGB) and to sure that all output images have the same number of channels . In this case the network is expecting [28 28 1] but by using 'ColorPreprocessing' to 'gray2rgb' the image set channels are converted from 1 to 3 because of which that particular error is thrown.
Try removing the ColorPreprocessing name value argument and I believe it should work.
Hope this helps!

Ebru PEKEL
Ebru PEKEL 2020 年 1 月 31 日
When you mean "augmentedTrainingSet "? It is size in [28 28]

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by