How to Solve this, Semantic Segmentation with Dice Loss

조회 수: 6 (최근 30일)
Mohammad Bhat
Mohammad Bhat 2019년 12월 18일
댓글: Mohammad Bhat 2019년 12월 21일
My images are with 256 X 256 in size
I am doing semantic segmentation with dice loss.
ds = pixelLabelImageDatastore(imdsTrain,pxdsTrain);
layers = [
imageInputLayer([256 256 1])
convolution2dLayer(3,32,'Padding',1)
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding',1)
reluLayer
transposedConv2dLayer(4,32,'Stride',2,'Cropping',1)
reluLayer
transposedConv2dLayer(4,32,'Stride',2,'Cropping',1)
convolution2dLayer(1,3)
softmaxLayer
dicePixelClassificationLayer('dice')
]
opts = trainingOptions('sgdm', 'InitialLearnRate',1e-3, 'MaxEpochs',10, 'LearnRateDropFactor',1e-1, 'LearnRateDropPeriod',50, 'LearnRateSchedule','piecewise', 'MiniBatchSize',32);
net = trainNetwork(ds,layers,opts);
Errors are :-
Error using trainNetwork (line 165)
Invalid training data. The output size ([512 512 3]) of the last layer does not match the response size ([256 256 3]).
Error in net_net (line 110)
net = trainNetwork(ds,layers,opts);
The output size ([512 512 3]) of the last layer does not match the response size ([256 256 3]).
  댓글 수: 4
Walter Roberson
Walter Roberson 2019년 12월 18일
I do not know what the cause of the problem is, but you could try adding a resize layer on the bottom.
Mohammad Bhat
Mohammad Bhat 2019년 12월 21일
I solved the problem rather error by adding maxpooling layer at the end....
.......................................................................
......................................................................
layers = [
imageInputLayer([256 256 1])
convolution2dLayer(3,32,'Padding',1)
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding',1)
reluLayer
transposedConv2dLayer(4,32,'Stride',2,'Cropping',1)
reluLayer
transposedConv2dLayer(4,32,'Stride',2,'Cropping',1)
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(1,3)
softmaxLayer
dicePixelClassificationLayer('dice')
]

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by