How to Solve this, Semantic Segmentation with Dice Loss

6 vues (au cours des 30 derniers jours)
Mohammad Bhat
Mohammad Bhat le 18 Déc 2019
Commenté : Mohammad Bhat le 21 Déc 2019
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 commentaires
Walter Roberson
Walter Roberson le 18 Déc 2019
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 le 21 Déc 2019
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')
]

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by