【问题标题】:Feature extraction from AlexNet fc7 layer in MATLAB在 MATLAB 中从 AlexNet fc7 层提取特征
【发布时间】:2018-09-16 18:33:41
【问题描述】:

我在 MATLAB 中有这个 AlexNet 模型:

net = alexnet;
layers = net.Layers;
layers(end-2) = fullyConnectedLayer(numClasses);
layers(end) = classificationLayer;

我正在使用它从不同类别视频的帧序列中学习特征。因此,我需要从该模型的“fc7”层中提取学习到的特征,以将这些特征保存为向量并将其传递给 LSTM 层。 这个迁移学习模型的训练过程还可以,好吧。

我在 imageDatastore() 中使用 splitEachLabel() 将数据集划分为 x_train 和 x_test 集,并使用函数 augmentedImageSource() 调整网络中所有图像的大小。一切正常!

但是当我尝试使用下面显示的代码的 sn-p 来调整我的 imageDatastore 中的图像大小以由函数激活()读取时,以将特征保存为向量,我得到一个错误:

imageSize = [227 227 3];
auimds = augmentedImageSource(imageSize, imds, 'ColorPreprocessing', 'gray2rgb');

功能激活:

layer = 'fc7';
fclayer = activations(mynet, auimds, layer,'OutputAs','columns');

错误:

Error using SeriesNetwork>iDataDispatcher (line 1113)
For an image input layer, the input data for predict must be a single image, a 4D array of images, or an imageDatastore with the correct size.

Error in SeriesNetwork/activations (line 791)
            dispatcher = iDataDispatcher( X, miniBatchSize, precision, ...

请有人帮助我! 感谢支持!

【问题讨论】:

    标签: matlab machine-learning deep-learning feature-extraction


    【解决方案1】:

    您是否检查过该层的输入大小?您得到的错误与当前层的输入大小有关。您可以在 Matlab 的工作区中检查您的 mynet 结构及其 fc7 层输入的大小吗?

    【讨论】:

      猜你喜欢
      • 2019-01-01
      • 1970-01-01
      • 2017-11-01
      • 2018-07-04
      • 2018-08-20
      • 2012-02-16
      • 1970-01-01
      • 1970-01-01
      • 2018-08-18
      相关资源
      最近更新 更多