The training image are the size of [32 32 32 4] but the input layer expects image size [32 32 32 3]
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I train the network the following :
imageDir=fullfile(tempdir,'PP');
if ~exist(imageDir,'dir')
mkdir(imageDir);
end
sourceDatalaoc=[imageDir filesep 'Brain'];
volc=fullfile (sourceDatalaoc, 'AA')
if~ exist(volc,'dir')
mkdir(volc);
end
loc=fullfile (sourceDatalaoc, 'BB')
if~ exist(loc,'dir')
mkdir(loc);
end
imds = imageDatastore(volc,'FileExtensions','.nii','ReadFcn',@sampleReadeFcn);
classNames = ["edema","nonEnhancingTumor","enhancingTumour"];
pixelLabelID = [1 2 3];
pxds = pixelLabelDatastore(loc,classNames,pixelLabelID,'FileExtensions','.nii','ReadFcn',@sampleReadeFcn);
V = read(imds);
L = read(pxds);
%h = labelvolshow(L,V(:,:,:,1));
pximds = pixelLabelImageDatastore(imds,pxds);
inputPatchSize = [32 32 32 4];
numClasses = 2;
patchSize = [32 32 32];
patchPerImage = 8;
miniBatchSize = 16;
patchds = randomPatchExtractionDatastore(imds,pxds,patchSize, ...
'PatchesPerImage',patchPerImage);
patchds.MiniBatchSize = miniBatchSize;
layers = [
image3dInputLayer([32 32 32 3)
convolution3dLayer(3,12,'Stride',1,'Padding','Same')
batchNormalizationLayer
reluLayer
transposedConv3dLayer(3,6,'Stride',1,'Cropping',1)
batchNormalizationLayer
reluLayer
convolution3dLayer(1,2)
softmaxLayer
pixelClassificationLayer
]
opts = trainingOptions('sgdm', ...
'InitialLearnRate',1e-3, ...
'ExecutionEnvironment','CPU',...
'MaxEpochs',100);
[net2,info] = trainNetwork(patchds,layers,opts);
Error:The training image are the size of [32 32 32 4] but the input layer expects image size [32 32 32 3]
1 commentaire
Walter Roberson
le 4 Nov 2020
There is no image input layer that can handle 4d but nifti files can be 4d (with time if I recall correctly)
How do you want to handle the fact that your input has a time dimension?
Réponses (2)
Walter Roberson
le 5 Nov 2020
You are trying to create a deep network using image processing layers, but your data is 4D. None of the available image layers support 4D.
If your 4th dimension represents time, then you should be considering a sequence layer; https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.sequenceinputlayer.html
0 commentaires
Voir également
Catégories
En savoir plus sur Pattern Recognition and Classification 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!