MATLAB Answers

No appropriate method, property, or field 'Files' for class 'augmented​ImageDatas​tore'.

22 views (last 30 days)
Jiagui LI
Jiagui LI on 30 Jun 2020
Edited: Jiagui LI on 2 Jul 2020
Hi,
I am trying to apply "Train Deep Learning Network to Classify New Images". I did test exactly according to
But I always got some problem as:
"No appropriate method, property, or field 'Files' for class 'augmentedImageDatastore'.
Error in googlenetJIAGUI (line 88)
valFrequency = floor(numel(augimdsTrain.Files)/miniBatchSize);"
When I ran:
%Train Network
pixelRange = [-30 30];
scaleRange = [0.9 1.1];
imageAugmenter = imageDataAugmenter( ...
'RandXReflection',true, ...
'RandXTranslation',pixelRange, ...
'RandYTranslation',pixelRange, ...
'RandXScale',scaleRange, ...
'RandYScale',scaleRange);
augimdsTrain = augmentedImageDatastore(inputSize(1:2),imdsTrain, ...
'DataAugmentation',imageAugmenter);
augimdsValidation = augmentedImageDatastore(inputSize(1:2),imdsValidation);
%Specify the training options.
miniBatchSize = 10;
valFrequency = floor(numel(imdsValidation.Files)/miniBatchSize); %%valFrequency = floor(numel(augimdsTrain.Files)/miniBatchSize);
options = trainingOptions('sgdm', ...
'MiniBatchSize',miniBatchSize, ...
'MaxEpochs',6, ...
'InitialLearnRate',3e-4, ...
'Shuffle','every-epoch', ...
'ValidationData',augimdsValidation, ...
'ValidationFrequency',valFrequency, ...
'Verbose',false, ...
'Plots','training-progress');
I check inside of "augimdsTrain", there is no "Files". When I replace with the "valFrequency = floor(numel(augimdsTrain.Files)/miniBatchSize);" with "valFrequency = floor(numel(imdsValidation.Files)/miniBatchSize)" . "valFrequency = floor(numel(augimdsTrain.Files)/miniBatchSize);" It seems to work.
Any body could tell me whether I am right?
Best regards,
jiagui

  4 Comments

Show 1 older comment
Jiagui LI
Jiagui LI on 1 Jul 2020
Thanks for help. it showed as following
>> disp(augimdsTrain)
augmentedImageDatastore with properties:
MiniBatchSize: 10
NumObservations: 55
DataAugmentation: [1×1 imageDataAugmenter]
ColorPreprocessing: 'none'
OutputSize: [224 224]
OutputSizeMode: 'resize'
DispatchInBackground: 0
Ameer Hamza
Ameer Hamza on 2 Jul 2020
On which platform are you running MATLAB R2020a? When I run it, the augmentedImageDatastore does have a field named Files.
>> disp(augimdsTrain)
augmentedImageDatastore with properties:
NumObservations: 55
Files: {55×1 cell}
AlternateFileSystemRoots: {}
MiniBatchSize: 128
DataAugmentation: [1×1 imageDataAugmenter]
ColorPreprocessing: 'none'
OutputSize: [227 227]
OutputSizeMode: 'resize'
DispatchInBackground: 0
Jiagui LI
Jiagui LI on 2 Jul 2020
Thank you.
I just found that indeed "disp(augimdsTrain)" is showed as you posted in my personal computer (Windows). But somehow it is not working in my office computer (linux). Both are 2020a
You also answered the questions.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 1 Jul 2020
Hack way:
old_warning_state = warning('off', 'MATLAB:structOnObject');
temp = struct(augimdsValidation);
warning(old_warning_state);
valFrequency = floor(numel(temp.DatastoreInternal.Files)/miniBatchSize);

  3 Comments

Jiagui LI
Jiagui LI on 1 Jul 2020
Thanks, it still showes:
>> old_warning_state = warning('off', 'MATLAB:structOnObject');
temp = struct(augimdsValidation);
warning(old_warning_state);
valFrequency = floor(numel(temp.DatastoreInternal.Files)/miniBatchSize);
No appropriate method, property, or field 'Files' for class 'nnet.internal.cnn.ImageDatastoreMiniBatchDatastore'.
Ameer Hamza
Ameer Hamza on 2 Jul 2020
Jiagui, try the following line
valFrequency = floor(numel(temp.DatastoreInternal.NumObservations)/miniBatchSize);
% or maybe this
valFrequency = floor(numel(temp.Files)/miniBatchSize);
Jiagui LI
Jiagui LI on 2 Jul 2020
Thanks a lot, that is working now as this:
old_warning_state = warning('off', 'MATLAB:structOnObject');
temp = struct(augimdsTrain); %% augimdsTrain , as the website. I should not use augimadsValidation
warning(old_warning_state);
valFrequency = floor(numel(temp.Files)/miniBatchSize);

Sign in to comment.

More Answers (0)


Translated by