Invalid Training Data; The output size ([512 640 2]) of the last later doesnt match the response size ([1 1 2]).
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Matt J
le 25 Jan 2024
The error has to do with the training data that you are providing, which we cannot see.
Réponses (1)
SOUMNATH PAUL
le 13 Fév 2024
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 commentaires
Voir également
Catégories
En savoir plus sur Image Data Workflows dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!