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

조회 수: 1 (최근 30일)
Mohammad Bhat
Mohammad Bhat 2019년 12월 20일
편집: per isakson 2019년 12월 21일
%------------------------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
Guillaume
Guillaume 2019년 12월 20일
The error message seems clear to me, your neural net expects 256x256 image but is getting 512x512 images.
I know nothing about the neural net toolbox so can't help any further.
Mohammad Bhat
Mohammad Bhat 2019년 12월 21일
편집: per isakson 2019년 12월 21일
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')
]

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

답변 (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