invalid training data for following code?

조회 수: 1 (최근 30일)
hla hla myint
hla hla myint 2020년 11월 2일
Error : The output size [132 132132 6] of the last payer does not match the response size [132 132 132 3]
My code is 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
%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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Pattern Recognition and Classification에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by