学習済みモデルのゆくえについて
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
alexnetで転写学習を行ったのですが、ネットワークモデルがどこに保存されているのかわからず困っています。 教えて下さい。
Accepted Answer
Hirokazu Tanaka
on 2 Aug 2018
3 votes
実際に実行された内容(コード)をみないと何とも言えませんが、どういった状況でしょうか?
例1:学習後のネットワークを mat ファイルに保存などの作業を行わず MATLAB を終了した場合: 学習結果は消えてしまっています。
例2:trainNetwork 関数を出力なしで実行した場合:実行直後は ans という変数名として存在するはずですが、その後上書きされている可能性はあります。
6 Comments
chihiro sasaya
on 3 Aug 2018
Edited: michio
on 3 Aug 2018
チュートリアルの構文をなぞり実行しました。
imds = imageDatastore('MerchData', ...
'IncludeSubfolders',true, ...
'LabelSource','foldernames');
[imdsTrain,imdsValidation] = splitEachLabel(imds,0.7,'randomized');
net = alexnet;
layersTransfer = net.Layers(1:end-3);
numClasses = numel(categories(imdsTrain.Labels));
layers = [
layersTransfer
fullyConnectedLayer(numClasses,'WeightLearnRateFactor',20,'BiasLearnRateFactor',20)
softmaxLayer
classificationLayer];
pixelRange = [-30 30];
imageAugmenter = imageDataAugmenter( ...
'RandXReflection',true, ...
'RandXTranslation',pixelRange, ...
'RandYTranslation',pixelRange);
augimdsTrain = augmentedImageDatastore(inputSize(1:2),imdsTrain, ...
'DataAugmentation',imageAugmenter);
augimdsValidation = augmentedImageDatastore(inputSize(1:2),imdsValidation);
options = trainingOptions('sgdm', ...
'MiniBatchSize',10, ...
'MaxEpochs',6, ...
'InitialLearnRate',1e-4, ...
'ValidationData',augimdsValidation, ...
'ValidationFrequency',3, ...
'ValidationPatience',Inf, ...
'Verbose',false, ...
'Plots','training-progress');
netTransfer = trainNetwork(augimdsTrain,layers,options);
YPred = predict(classifier,featuresTest);
idx = randperm(numel(imdsValidation.Files),4);
figure
for i = 1:4
subplot(2,2,i)
I = readimage(imdsValidation,idx(i));
imshow(I)
label = YPred(idx(i));
title(string(label));
end
Hirokazu Tanaka
on 3 Aug 2018
netTransfer = trainNetwork(augimdsTrain,layers,options);
とある通り、転移学習後のネットワークは netTransfer のように見受けられます。ただその直後の
YPred = predict(classifier,featuresTest);
がよくわかりませんでした。classifier はどこから来たのでしょう。
どのページにあるチュートリアルなのか、使っているMATLABバージョン情報もあればうれしいですが、、その前にお困りの点は何でしょうか?
chihiro sasaya
on 3 Aug 2018
Edited: chihiro sasaya
on 3 Aug 2018
分かりづらくすみません。ご解答ありがとうございます。 alexnetをつかって、転移学習を行なった後のネットワークを使い自分で撮ってきた画像をつかって実験をしてみようと思っています。 現段階で転移後のネットワークモデルの場所が分からず困っていた次第です。
https://jp.mathworks.com/help/nnet/ref/alexnet.html
この中盤辺りの 事前学習済みのネットワークの読み込み の所から サンプルのデータを変えて見ておこないました。
バージョンは、'9.4.0.813654 (R2018a)' です。
Hirokazu Tanaka
on 4 Aug 2018
詳細ありがとうございます。おそらく「AlexNet を使用した転移学習」というサンプルコードのことだと思いますが、
netTransfer = trainNetwork(augimdsTrain,layers,options);
のコマンドで転移層と新しい層とで構成されるネットワークを学習していますので、netTransfer がお探しの「転移後のネットワークモデル」になるのかと思うのですがいかがでしょう。「モデルの場所」というものが今少し理解できずにおります・・。
chihiro sasaya
on 5 Aug 2018
ご回答ありがとうございます。 うまくいきました! 最近まで違うツールでネットワークを触っていて、その感じ学習済みモデルというものが生成されるのかなと思いこのように書いてしまいました。 教えていただいて本当に感謝しています!
Hirokazu Tanaka
on 5 Aug 2018
うまくいったようで、よかったです :) サンプルを実行してみるのもいいですが、こちらの「ディープラーニング入門」コースも無料ですし感触をつかむにはお勧めですよ。
More Answers (0)
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
See Also
on 2 Aug 2018
on 5 Aug 2018
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)