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!