I am trying to find deep learned features at fc7 layer of alexnet
4 ビュー (過去 30 日間)
古いコメントを表示
I am trying to find deep learned features at fc7 layer of alexnet using the below code:
close all;
clear all;
clc;
run './matconvnet/matlab/vl_setupnn'
% Load pre-trained AlexNet
net = alexnet;
% Load an example image
im = imread('01.jpg');
% Resize the image to the input size of AlexNet
im = imresize(im, [227 227]);
% Preprocess the image for AlexNet
im = im2single(im);
%im = im - net.meta.normalization.averageImage;
for j=1:3
im(:,:,j) = im(:,:,j) - net.meta.normalization.averageImage(j);
end
% Extract features at fc7 layer
features = activations(net, im, 'fc7');
% Display the extracted features
disp(features);
I am getting this error:
Unrecognized method, property, or field 'meta' for class 'SeriesNetwork'.
Error in alexnet_fc7 (line 19)
im(:,:,j) = im(:,:,j) - net.meta.normalization.averageImage(j);
0 件のコメント
採用された回答
Himanshu
2023 年 3 月 27 日
Hello Aditya,
As per my understanding, you are facing an error while extracting the features from the "fc7" Fully Connected Layer of the AlexNet Convolutional Neural Network.
The error occurs because you are trying to access the "meta" field of the "net" object, which doesn't exist in the "SeriesNetwork" class.
As per the provided code, I understand that you want to normalize the input data by subtracting the mean of the dataset images. You can perform the operation by replacing the "for" loop with the following code:
average_image = mean(net.Layers(1).Mean(1,:), 2)
im = bsxfun(@minus, im, average_image)
Here, it first calculates the average image value using the "Mean" property of the first layer and then subtracts it from the input image.
You can refer to the below documentation to understand more about the "AlexNet", "SeriesNetwork" and "bsxfun" function.
その他の回答 (0 件)
参考
カテゴリ
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!