Semantic segmentation network - different behaviour on different systems
Mostrar comentarios más antiguos
Hello,
i'm trying to train a semantic segmentation network to recognize certain areas in an image. So i labeled some images as train data and save them in 'gTruth.mat' and trained the network succesfully.
This works very fine when training the network on my laptop with Matlab 2022a without any error.
When I try the same code on my workstation where I have Matlab 2022b and 2018b installed, I get the following error message:
"Error using trainNetwork Invalid training data. The output size ([500 500 2]) of the last layer does not match the response size ([538 679 2])."
Why do I get different output sizes with the same code on two different systems? Or is this a special 2022a issue?
load('gTruth.mat');
classNames = {gTruth.LabelDefinitions.Name{1}, gTruth.LabelDefinitions.Name{2}};
[imdsTrain,pxdsTrain] = pixelLabelTrainingData(gTruth);
pximdsTrain = pixelLabelImageDatastore(imdsTrain,pxdsTrain);
tbl = countEachLabel(pxdsTrain);
numberPixels = sum(tbl.PixelCount);
frequency = tbl.PixelCount / numberPixels;
classWeights = 1 ./ frequency;
inputSize = [500 500 1];
filterSize = 3;
numFilters = 32;
numClasses = numel(classNames);
layers = [
imageInputLayer(inputSize)
convolution2dLayer(filterSize,numFilters,'DilationFactor',1,'Padding','same')
batchNormalizationLayer
reluLayer
convolution2dLayer(filterSize,numFilters,'DilationFactor',2,'Padding','same')
batchNormalizationLayer
reluLayer
convolution2dLayer(filterSize,numFilters,'DilationFactor',4,'Padding','same')
batchNormalizationLayer
reluLayer
convolution2dLayer(1,numClasses)
softmaxLayer
pixelClassificationLayer('Classes',classNames,'ClassWeights',classWeights)];
options = trainingOptions('sgdm', ...
'MaxEpochs', 15, ...
'MiniBatchSize',64, ...
'InitialLearnRate', 1e-3,...
'ExecutionEnvironment','cpu');
net = trainNetwork(pximdsTrain,layers,options);
Thanks in advance for your help
Respuesta aceptada
Más respuestas (1)
snipsnap333
el 12 de Mayo de 2023
0 votos
Categorías
Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!