Why I received an error when extracting feature using Alexnet?

조회 수: 3(최근 30일)
Hello everyone!
I'm doing gait recognition based on front view and back view for my final year project. I'm trying to train an AlexNet model to Feature Extraction and i'm getting the following problems:
I'm getting the following errors:
Error using SeriesNetwork/activations (line 790)
The input images for activations must be of size equal to or greater than [227 227 3].
Error in Untitled (line 22)
featuresTrain = activations(net,imdsTrain,layer,'OutputAs','rows');
My code:
clc
clear all
close all
%% Loading the image data
imds = imageDatastore('C:\Users\lenovo\Desktop\Image Classification\resizedFrontView', ...
'IncludeSubfolders',true,'LabelSource','foldernames');
%% Cross-Validation using Hold-out method
[imdsTrain,imdsTest] = splitEachLabel(imds,0.7,'randomized');
%% CNN model is loaded
net = alexnet;
%% Final fully-connected
layer = 'fc8'
%% CNN model, images & layers are passed to extract the CNN from train & test
featuresTrain = activations(net,imdsTrain,layer,'OutputAs','rows');
featuresTest = activations(net,imdsTest,layer,'OutputAs','rows');
Someone can help me?
Thank you for your support
  댓글 수: 1
Mainur Rahman
Mainur Rahman 2021년 2월 12일
Did you solve it?? I am facing same problem

댓글을 달려면 로그인하십시오.

답변(1개)

vaibhav mishra
vaibhav mishra 2020년 6월 30일
Hi there,
I can think of two methods to solve this problem.
1-Try to resize each image to [227,227,3] with image = imresize(image, [227, 227]); and then feed it as the input. Also check for the number of channels for each image, some image have only one channel and they can cause problem while taking input to model.
you can also use the augmentedImageDatastore to change the size of images collectively.
audimds=augmentedImageDatastore([227 227],imds);
2- Try to add more layers to the layer variable. Maybe like layer=net.Layers and then add the 'fc8' layer with layer{end}='fc8'
  댓글 수: 1
Mainur Rahman
Mainur Rahman 2021년 2월 12일
편집: Mainur Rahman 2021년 2월 12일
i converted the size to [227,227,3], but same problem. can you please run this code once for me?? It will be really helpful for me.
Thanks in advance

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by