MATLAB中AlexNet fc7层的特征提取
Feature extraction from AlexNet fc7 layer in MATLAB
我在 MATLAB 中有这个 AlexNet 模型:
net = alexnet;
layers = net.Layers;
layers(end-2) = fullyConnectedLayer(numClasses);
layers(end) = classificationLayer;
我正在使用它从不同 类 视频的帧序列中学习特征。所以我需要从这个模型的 'fc7' 层中提取学习到的特征,将这些特征保存为一个向量并将其传递给 LSTM 层。
这个迁移学习模型的训练过程还可以,好的。
我在 imageDatastore() 中使用 splitEachLabel() 将我的数据集分为 x_train 和 x_test 组,并使用函数 augmentedImageSource() 调整网络中所有图像的大小.一切正常!
但是当我尝试使用下面显示的这段代码来调整我的 imageDatastore 中的图像的大小以供函数 activations() 读取时,将特征保存为向量时,我收到一个错误:
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 的工作区中检查你的 mynet 结构及其 fc7 层输入的大小吗?
我在 MATLAB 中有这个 AlexNet 模型:
net = alexnet;
layers = net.Layers;
layers(end-2) = fullyConnectedLayer(numClasses);
layers(end) = classificationLayer;
我正在使用它从不同 类 视频的帧序列中学习特征。所以我需要从这个模型的 'fc7' 层中提取学习到的特征,将这些特征保存为一个向量并将其传递给 LSTM 层。 这个迁移学习模型的训练过程还可以,好的。
我在 imageDatastore() 中使用 splitEachLabel() 将我的数据集分为 x_train 和 x_test 组,并使用函数 augmentedImageSource() 调整网络中所有图像的大小.一切正常!
但是当我尝试使用下面显示的这段代码来调整我的 imageDatastore 中的图像的大小以供函数 activations() 读取时,将特征保存为向量时,我收到一个错误:
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 的工作区中检查你的 mynet 结构及其 fc7 层输入的大小吗?