errors in using transform for imagedatastore in deep learning

1 vue (au cours des 30 derniers jours)
Frank Liu
Frank Liu le 5 Juil 2020
Commenté : Frank Liu le 9 Juil 2020
A part of source code:
dsnew_trn = transform(ds_trn, @(x) GFR2filter_crop(x, kerfcn, s1, s2, inputSize));
dsnew_tst = transform(ds_tst, @(x) GFR2filter_crop(x, kerfcn, s1, s2, inputSize));
trainedNet = trainNetwork(dsnew_trn,lgraph,opts);
ds_trm: original imagedatastore for training; read images by using a custom function, output: double type
ds_tst: original imagedatasotre for testing; the same to the above.
batch size: 64
function dataout = GFR2filter_crop(dataIn, kerfcn, s1, s2, inputSize)
NoImg = size(dataIn);
dataout = cell(NoImg,1);
for xxx=1:NoImg
Img = dataIn{xxx};
%}
I_spatial = Img(:,:,1);
R1 = imfilter(I_spatial, kerfcn);
trasImg(:,:,1)=R1(s1:s1+inputSize(1)-1,s2:s2+inputSize(2)-1);
I_spatial = Img(:,:,2);
R2 = imfilter(I_spatial, kerfcn);
trasImg(:,:,2)=R2(s1:s1+inputSize(1)-1,s2:s2+inputSize(2)-1);
I_spatial = Img(:,:,3);
R3 = imfilter(I_spatial, kerfcn);
trasImg(:,:,3)=R3(s1:s1+inputSize(1)-1,s2:s2+inputSize(2)-1);
dataout{xxx}=trasImg;
end
-----------------------------------
Error message:
Error using trainNetwork (line 170)
Invalid transform function defined on datastore.
Error in alaska2_deeplearningxx (line 74)
trainedNet = trainNetwork(dsnew_trn,lgraph,opts);
Caused by:
Error using nnet.internal.cnn.util.NetworkDataValidator/assertDatastoreHasResponses (line 140)
Invalid transform function defined on datastore.
Error using cell
Size inputs must be scalar.
  3 commentaires
Bhargavi Maganuru
Bhargavi Maganuru le 9 Juil 2020
Makesure the input to the transform is a datastore . Could you mention the version of MATLAB you are using?
Frank Liu
Frank Liu le 9 Juil 2020
Hi, I already solve the proveblem. Regarding the transform function in matlab, it has the fixed input signature as the follows,
dsnew = transform(ds,@fcn)
dsnew = transform(ds,@fcn,'IncludeInfo',IncludeInfo)
therefore, the original functions
dsnew_trn = transform(ds_trn, @(x) GFR2filter_crop(x, kerfcn, s1, s2, inputSize));
dsnew_tst = transform(ds_tst, @(x) GFR2filter_crop(x, kerfcn, s1, s2, inputSize));
has been modified into the followings. Meanwhile, kerfcn, s1, s2 and inputSize are set as global variables.
dsnew_trn = transform(ds_trn, @GFR2filter_crop,'IncludeInfo',IncludeInfo);
dsnew_tst = transform(ds_tst, @GFR2filter_crop,'IncludeInfo',IncludeInfo);

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by