Why I received an error when extracting feature using Alexnet?

2 vues (au cours des 30 derniers jours)
NUR AQILAH ZULKAPLI
NUR AQILAH ZULKAPLI le 27 Juin 2020
Modifié(e) : Mainur Rahman le 12 Fév 2021
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

Réponses (1)

vaibhav mishra
vaibhav mishra le 30 Juin 2020
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 commentaire
Mainur Rahman
Mainur Rahman le 12 Fév 2021
Modifié(e) : Mainur Rahman le 12 Fév 2021
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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by