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 件)
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
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
参考
カテゴリ
Help Center および File Exchange で Image Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!