invalid training data in matlab?

2 views (last 30 days)
hla hla myint
hla hla myint on 2 Nov 2020
My Code :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
%matReader = @samplePXDSMatReader;
imds = imageDatastore(volc,'FileExtensions','.nii','ReadFcn',@sampleReadeFcn);
%auimds = augmentedImageDatastore([64 64 64 ],imds)
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 = [132 132 132 4];
numClasses = 2;
patchSize = [132 132 132];
patchPerImage = 8;
miniBatchSize = 16;
patchds = randomPatchExtractionDatastore(imds,pxds,patchSize, ...
'PatchesPerImage',patchPerImage);
patchds.MiniBatchSize = miniBatchSize;
layers = [
image3dInputLayer([132 132 132 4])
convolution3dLayer(3,12,'Stride',1,'Padding','Same')
batchNormalizationLayer
reluLayer
transposedConv3dLayer(3,12,'Stride',1,'Cropping',1)
batchNormalizationLayer
reluLayer
transposedConv3dLayer(3,6,'Stride',1,'Cropping',1)
softmaxLayer
pixelClassificationLayer
]
opts = trainingOptions('sgdm', ...
'InitialLearnRate',1e-3, ...
'ExecutionEnvironment','CPU',...
'MaxEpochs',100);
[net2,info] = trainNetwork(patchds,layers,opts);close
function data = sampleReadeFcn(filename)
data = niftiread(filename)
end
Error: The output size[132 132 132 6] of the last layer does not match the reponse size[132 132 132 3 ]

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!