Error using activations functions in matlab
6 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I trying to replace the pre-trained CNN fully connected layer with mine 'new_fc'.
imds = imageDatastore('MerchData', 'IncludeSubfolders',true, 'LabelSource','foldernames');
[imdsTrain,imdsValidation] = splitEachLabel(imds,0.7);
testnet = resnet18
inputSize = testnet.Layers(1).InputSize
augimdsTrain = augmentedImageDatastore(inputSize(1:2),imdsTrain)
augimdsValidation = augmentedImageDatastore(inputSize(1:2),imdsValidation)
if isa(learnableLayer,'nnet.cnn.layer.FullyConnectedLayer')
newLearnableLayer = fullyConnectedLayer(7, ...
'Name','new_fc', ...
'WeightLearnRateFactor',10, ...
'BiasLearnRateFactor',10);
elseif isa(learnableLayer,'nnet.cnn.layer.Convolution2DLayer')
newLearnableLayer = convolution2dLayer(1,7, ...
'Name','new_conv', ...
'WeightLearnRateFactor',10, ...
'BiasLearnRateFactor',10);
end
lgraph = replaceLayer(lgraph,learnableLayer.Name,newLearnableLayer)
newClassLayer = classificationLayer('Name','new_classoutput')
lgraph = replaceLayer(lgraph,classLayer.Name,newClassLayer)
layer = 'new_fc';
activations(lgraph,augimdsTrain,layer,'OutputAs','rows')
The error message that i got is as below.
"check for incorrect argument data type or missing argument in call to function 'activations'.
Hope someone could help on this. Thank you in advance.
0 件のコメント
採用された回答
yanqi liu
2022 年 3 月 23 日
yes,sir,if modify net structure,may be need retrain it,then use activations to get feature
so,may be use
featuresTrain = activations(testnet,augimdsTrain,'fc1000','OutputAs','rows')
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Install Products についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!