u-netによるセマンティックセグメンテーション

深層学習を使用したセマンティック セグメンテーションをもとにU-netを用いて自分で用意したデータセットでセマンティックセグメンテーションを行ったところ以下のようなエラーが発生しました.
>> i_learning
エラー: nnet.cnn.LayerGraph>iValidateLayerName (line 663)
'pixelLabels' は存在しません。
エラー: nnet.cnn.LayerGraph/removeLayers (line 234)
iValidateLayerName( ...
エラー: i_learning (line 17)
lgraph = removeLayers(lgraph,'pixelLabels');
以下にi_learningのコードを示します.
%ネットワークの作成
imageSize = [352 480 3];
%imageSize = [180 240 3];
numClasses = numel(classes);
lgraph = unetLayers(imageSize,numClasses);
%クラスの重み付けを使用したクラスのバランス調整
imageFreq = tbl.PixelCount ./ tbl.ImagePixelCount;
classWeights = median(imageFreq) ./ imageFreq;
pxLayer = pixelClassificationLayer('Name','labels','ClassNames',tbl.Name,'ClassWeights',classWeights);
lgraph = removeLayers(lgraph,'pixelLabels');  %エラー発生箇所
lgraph = addLayers(lgraph, pxLayer);
lgraph = connectLayers(lgraph,'softmax','labels');
%学習オプションの選択
options = trainingOptions('sgdm', ...
'Momentum',0.9, ...
'InitialLearnRate',1e-3, ...
'L2Regularization',0.0005, ...
'MaxEpochs',200, ...
'MiniBatchSize',1, ...
'Shuffle','every-epoch', ...
'VerboseFrequency',2);
%データ拡張
augmenter = imageDataAugmenter('RandXReflection',true,...
'RandXTranslation',[-10 10],'RandYTranslation',[-10 10]);
%学習の開始
pximds = pixelLabelImageDatastore(imdsTrain,pxdsTrain,'DataAugmentation',augmenter);
net= trainNetwork(pximds,lgraph,options);

1 Kommentar

Kodai Sato
Kodai Sato am 6 Jan. 2020
lgraph = removeLayers(lgraph,'pixelLabels');
lgraph = addLayers(lgraph, pxLayer);
lgraph = connectLayers(lgraph,'softmax','labels');
上のコードの部分を書き換えればいいのでしょうが,層の名前がわかりません.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

michio
michio am 8 Jan. 2020

1 Stimme

層の名前であれば
lgraph.Layers
と実行したときに確認できると思いましたがいかがでしょう。

1 Kommentar

Kodai Sato
Kodai Sato am 10 Jan. 2020
無事確認できました
ありがとうございました

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2019b

Gefragt:

am 6 Jan. 2020

Kommentiert:

am 10 Jan. 2020

Community Treasure Hunt

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

Start Hunting!