How to Solve this, Semantic Segmentation with Dice Loss

5 次查看(过去 30 天)
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