3-D Brain Tumor Segmentation Using Deep Learning - Error using nnet.cnn.TrainingOptionsADAM (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 个评论
回答(1 个)
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
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
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 Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!