フィルターのクリア

I am trying to find deep learned features at fc7 layer of alexnet

4 ビュー (過去 30 日間)
Aditya
Aditya 2023 年 3 月 16 日
コメント済み: Aditya 2023 年 3 月 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);

採用された回答

Himanshu
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.
  1 件のコメント
Aditya
Aditya 2023 年 3 月 30 日
Thanks a lot Himanshu, This method is working and I am getting the output for the same.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by