MATLAB Answers

I am unable to find the errror.....

1 view (last 30 days)
Mohammad Bhat
Mohammad Bhat on 20 Dec 2019
Edited: per isakson on 21 Dec 2019
%------------------------Data STores--------------------------------------%
dataSetDir = 'C:\Users\idree\Desktop\Main\ultimate\'
imageDir = fullfile(dataSetDir,'o_binary');
labelDir = fullfile(dataSetDir,'l_binary');
imds = imageDatastore(imageDir);
%-------------------------------------------------------------------------%
classNames = ["shirorekha" "character" "background"];
labelIDs = [1 2 3];
pxds = pixelLabelDatastore(labelDir, classNames, labelIDs);
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
convolution2dLayer(1,3)
softmaxLayer
dicePixelClassificationLayer('dice')
]
ds = pixelLabelImageDatastore(imds,pxds);
options = trainingOptions('sgdm', ...
'InitialLearnRate',1e-3, ...
'MaxEpochs',100, ...
'LearnRateDropFactor',0.1, ...
'LearnRateDropPeriod',50, ...
'LearnRateSchedule','piecewise', ...
'MiniBatchSize',32);
net = trainNetwork(ds,layers,options);
-------------------------------------------------------------------------------------------------------
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 dice_try_data (line 35)
net = trainNetwork(ds,layers,options);
  2 Comments
Mohammad Bhat
Mohammad Bhat on 21 Dec 2019
I solved 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')
]

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!