invalid training data for following code?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!