ClassWeightsの設定方法

7 visualizaciones (últimos 30 días)
Kodai Sato
Kodai Sato el 18 de Dic. de 2019
Comentada: Kenta el 19 de Dic. de 2019
深層学習を使用したセマンティック セグメンテーションhttps://jp.mathworks.com/help/releases/R2018a/vision/examples/semantic-segmentation-using-deep-learning.html
をもとに自分で用意したデータセットで解析を行ったところ以下のようなエラーが出ました.
無題.png
以下にi_learningのコードを示します.
%ネットワークの作成
imageSize = [360 480 3];
numClasses = numel(classes);
lgraph = segnetLayers(imageSize,numClasses,'vgg16');
%クラスの重み付けを使用したクラスのバランス調整
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',100, ...
'MiniBatchSize',2, ...
'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);

Respuesta aceptada

Kenta
Kenta el 18 de Dic. de 2019
classWeights
と入力して、それぞれの値を教えてもらえますか?訓練データに、ある稀なラベルが含まれていなくて0で割っている状態なのではないかと思いました。
classWeights = median(imageFreq) ./ (imageFreq+0.0001);
などとすれば回避できると思いました。
  10 comentarios
Kodai Sato
Kodai Sato el 19 de Dic. de 2019
tbl.PixelCount
を実行したところこちらも0であったため
imageFreq = (tbl.PixelCount+1) ./ (tbl.ImagePixelCount+1);
としたところ実行できました
何度も申し訳ありませんでした
Kenta
Kenta el 19 de Dic. de 2019
はい、無事実行できてよかったです。

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!