MATLAB Answers

how can i make alexnet accept 277x277x1 images

158 views (last 30 days)
i got error in example TransferLearningUsingAlexNetExample Error using trainNetwork (line 140) The training images are of size 227x227x1 but the input layer expects images of size 227x227x3. my dataset 277X277x1

  2 Comments

SAQIB SHEIKH
SAQIB SHEIKH on 2 Sep 2019
you can use Software Faststone Image resizer
arun anoop m
arun anoop m on 17 Jul 2020
a=imread(' ');
l=alexnet;
a=imresize(a,[227 227]);
s=classify(l,a);
imshow(a);
try this.

Sign in to comment.

Accepted Answer

Brendan Hamm
Brendan Hamm on 29 Dec 2017
You can resize an image with the imresize function. Now since your images are of size 277x277x1 I will assume they are grayscale, but AlexNet was trained with RGB values and are thus 227x227x 3. It is not possible for you to recover color information from a grayscale image. You may be required to retrain the entire network with grayscale images.
I suggest for more questions on getting started with Deep Learning you check out the FREE Deep Learning OnRamp: https://matlabacademy.mathworks.com/

  8 Comments

Show 5 older comments
Walter Roberson
Walter Roberson on 2 Jan 2018
I suggest you consider converting your grayscale to RGB by taking
YourImage(:,:,[1 1 1])
or equivalently
repmat(YourImage, 1, 1, 3)
Brendan Hamm
Brendan Hamm on 9 Feb 2018
@abdo You can retrain by following the process in the doc:
You can also learn more through the both free and hands on training course Deep Learning Onramp. I highly recommend this approach if you are just getting started.
arun anoop m
arun anoop m on 17 Jul 2020
Thank you Brendan Hamm sir for recommending useful training course Deep Learning Onramp.

Sign in to comment.

More Answers (2)

Atika Aftab
Atika Aftab on 10 Feb 2020
how can i make [224 224 1] img size ?

  1 Comment

arun anoop m
arun anoop m on 17 Jul 2020
I hope
a=imread(' ');
a=imresize(a,[224 224]);

Sign in to comment.


Ayshath Afra
Ayshath Afra on 2 Apr 2020
The training images are of size 256x256x3 but the input layer expects images of size 224x224x3.
pls help me to solve this error

  1 Comment

Michael Keeling
Michael Keeling on 5 Jun 2020
You can make an augmented datastore of the images that resizes them auomatically, while leaving your raw images the same

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!