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

6 vues (au cours des 30 derniers jours)
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 commentaires
Moran Artzi
Moran Artzi le 6 Déc 2021
Thanks for your response
miniBatchSize = 8;
dsVal =
TransformedDatastore with properties:
UnderlyingDatastores: {randomPatchExtractionDatastore}
SupportedOutputFormats: [1×16 string]
Transforms: {@(patchIn)augmentAndCrop3dPatch(patchIn,outPatchSize,dataSource)}
IncludeInfo: 0
Lidia Gil Martinez
Lidia Gil Martinez le 27 Jan 2022
Hi,
I have the same issue, is there any solution?
Thanks,
Lidia

Connectez-vous pour commenter.

Réponses (1)

vadi su yilmaz
vadi su yilmaz le 3 Fév 2022
%%%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 commentaires
Lidia Gil Martinez
Lidia Gil Martinez le 7 Fév 2022
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 le 15 Fév 2022
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by