Why I received an error when extracting feature using Alexnet?

3 visualizaciones (últimos 30 días)
NUR AQILAH ZULKAPLI
NUR AQILAH ZULKAPLI el 27 de Jun. de 2020
Editada: Mainur Rahman el 12 de Feb. de 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

Respuestas (1)

vaibhav mishra
vaibhav mishra el 30 de Jun. de 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 comentario
Mainur Rahman
Mainur Rahman el 12 de Feb. de 2021
Editada: Mainur Rahman el 12 de Feb. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by