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 件)

Community Treasure Hunt

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

Start Hunting!

Translated by