3-D Brain Tumor Segmentation Using Deep Learning - Error using nnet.cnn.T​rainingOpt​ionsADAM (line 129)

조회 수: 6 (최근 30일)
runing Segment3DBrainTumorUsingDeepLearningExample [on Task01_BrainTumour data]:
options = trainingOptions('adam', ...
'MaxEpochs',50, ...
'InitialLearnRate',5e-4, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropPeriod',5, ...
'LearnRateDropFactor',0.95, ...
'ValidationData',dsVal, ...
'ValidationFrequency',400, ...
'Plots','training-progress', ...
'Verbose',false, ...
'MiniBatchSize',miniBatchSize);
I got the following error
Error using nnet.cnn.TrainingOptionsADAM (line 129)
The value of 'ValidationData' is invalid. Invalid transform function defined on datastore.
Error in trainingOptions (line 302)
opts = nnet.cnn.TrainingOptionsADAM(varargin{:});
Caused by:
Error using augmentAndCrop3dPatch
Too many input arguments.
any suggestions?
Thanks a lot
Moran
  댓글 수: 3
Moran Artzi
Moran Artzi 2021년 12월 6일
Thanks for your response
miniBatchSize = 8;
dsVal =
TransformedDatastore with properties:
UnderlyingDatastores: {randomPatchExtractionDatastore}
SupportedOutputFormats: [1×16 string]
Transforms: {@(patchIn)augmentAndCrop3dPatch(patchIn,outPatchSize,dataSource)}
IncludeInfo: 0

댓글을 달려면 로그인하십시오.

답변 (1개)

vadi su yilmaz
vadi su yilmaz 2022년 2월 3일
%%%I had the same problem and solved this with opening the function and change inside of it with code below,
function patchOut = augment3dPatch(patchIn)
flag='validation';
isValidationData = strcmp(flag,'validation');
inpVol = cell(size(patchIn,1),1);
inpResponse = cell(size(patchIn,1),1);
% 5 augmentations: nil,rot90,fliplr,flipud,rot90(fliplr)
fliprot = @(x) rot90(fliplr(x));
augType = {@rot90,@fliplr,@flipud,fliprot};
for id=1:size(patchIn,1)
rndIdx = randi(8,1);
tmpImg = patchIn.InputImage{id};
tmpResp = patchIn.ResponsePixelLabelImage{id};
if rndIdx > 4 || isValidationData
out = tmpImg;
respOut = tmpResp;
else
out = augType{rndIdx}(tmpImg);
respOut = augType{rndIdx}(tmpResp);
end
% Crop the response to to the network's output.
respFinal=respOut(45:end-44,45:end-44,45:end-44,:);
inpVol{id,1}= out;
inpResponse{id,1}=respFinal;
end
patchOut = table(inpVol,inpResponse);
%%% then delete the dsVal from Workspace completely because it will stores the previous one also and create it again then transform with code below,
dsVal = transform(dsVal,@augmentAndCrop3dPatch);
I hope it should be solved
  댓글 수: 2
Lidia Gil Martinez
Lidia Gil Martinez 2022년 2월 7일
Hi,
Thanks, it worked, but i get another error:
Error using trainNetwork (line 183)
Invalid transform function defined on datastore.
Caused by:
Error using matlab.io.datastore.TransformedDatastore/read (line 222)
Invalid transform function defined on datastore.
Error using augmentAndCrop3dPatch
Too many input arguments.
vadi su yilmaz
vadi su yilmaz 2022년 2월 15일
The problem is the same actually, you should make the same thing for traindata because you should adjust both train data and validation data. There are different way for apply this function to both dataset however I recomend you to adjust the code according to traindata(I adjust and indicate them with bold) and change the name of the function augment3dPatchs (I add s to end you can put another name), paste this function in new script and save,
function patchOut = augment3dPatchs(patchIn)
flag='Training';
traindata = strcmp(flag,'Training');
inpVol = cell(size(patchIn,1),1);
inpResponse = cell(size(patchIn,1),1);
% 5 augmentations: nil,rot90,fliplr,flipud,rot90(fliplr)
fliprot = @(x) rot90(fliplr(x));
augType = {@rot90,@fliplr,@flipud,fliprot};
for id=1:size(patchIn,1)
rndIdx = randi(8,1);
tmpImg = patchIn.InputImage{id};
tmpResp = patchIn.ResponsePixelLabelImage{id};
if rndIdx > 4 || traindata;
out = tmpImg;
respOut = tmpResp;
else
out = augType{rndIdx}(tmpImg);
respOut = augType{rndIdx}(tmpResp);
end
% Crop the response to to the network's output.
respFinal=respOut(45:end-44,45:end-44,45:end-44,:);
inpVol{id,1}= out;
inpResponse{id,1}=respFinal;
end
patchOut = table(inpVol,inpResponse);
%%% then apply
dsTrain = transform(patchds,@augmentAndCrop3dPatchs);
I hope it will solve.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by