Invalid Training Data; The output size ([512 640 2]) of the last later doesnt match the response size ([1 1 2]).
1 回表示 (過去 30 日間)
古いコメントを表示
I am using a basic CNN in the Deep Network Designer App. I took this code in 'imported from workspace' to the app. My images have both real images and their corresponding ground. The issue is that when I train my images I get this error Invalid Training Data; The output size ([512 640 2]) of the last later doesnt match the response size ([1 1 2]).
My images are all grey scale [512 640 1] which is consistant with the imageInputLayer but i cannot edit the pixelclassificationlayer at the end. How can i get around this issue.
numFilters = 16;
filterSize = 3;
numClasses = 2;
targetResponseSize = [512 640];
layers = [
imageInputLayer([512 640])
convolution2dLayer(filterSize,numFilters,'Padding',1)
reluLayer()
maxPooling2dLayer(2,'Stride',2)
%% down sample
convolution2dLayer(filterSize,numFilters,'Padding',1)
reluLayer()
transposedConv2dLayer(4,numFilters,'Stride',2,'Cropping',1);
%% up sample
convolution2dLayer(1,numClasses);
softmaxLayer()
% Assuming you have 2 classes and your target response size is [512 640]
pixelClassificationLayer("Classes",classNames);
];
opts = trainingOptions('sgdm', ...
'InitialLearnRate',1e-8, ...
'MaxEpochs',20, ...
'MiniBatchSize',1);
1 件のコメント
Matt J
2024 年 1 月 25 日
The error has to do with the training data that you are providing, which we cannot see.
回答 (1 件)
SOUMNATH PAUL
2024 年 2 月 13 日
It seems there's a mismatch between the output of your network and the format of your ground truth labels.Without the actual data to look at its difficult to address the exact cause. For pixel classification, the labels used should be the same spatial size as your input images, with each pixel classified as one of the two classes.
The error message suggests that the labels might be in an incorrect format or size. Kindly ensure that the ground truth labels are categorical matrices with dimensions [512 x 640], where each element corresponds to the class of each pixel.
Hope it helps!
Regards,
Soumnath
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Image Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!