Data Science Asked by Noran on August 30, 2020
I am using Keras to create a deep learning model and I would like to know that what is the difference between shuffle
argument in fit_generator()
method and shuffle
argument in flow_from_directory()
method?
From fit_generator()
documentation:
shuffle: Boolean. Whether to shuffle the order of the batches at the beginning of each epoch. Only used with instances of
Sequence
(keras.utils.Sequence
). Has no effect whensteps_per_epoch
is notNone
.
So if you are using a generator and set steps_per_epoch
it would have no effect. In case of using a Sequence
generator, it would get the batches in different order at each epoch. For example, in first epoch it might get my_seq[0]
and then my_seq[1]
and then my_seq[2]
(and so on) and in the second epoch it might get my_seq[2]
and then my_seq[0]
and then my_seq[1]
and so on for the next epochs (i.e. note that my_seq[i]
is the i-th batch generated by the Sequence
generator we have defined).
From flow_from_directory()
documentation:
shuffle: Whether to shuffle the data (default:
True
)
It is not clear when and how shuffling is done. So we must take a look at the source code. By doing so, we find out that flow_from_directory()
method returns an instance of DirectoryIterator
class which in its docstring we can see the following:
shuffle: Boolean, whether to shuffle the data between epochs.
So it would shuffle all of the data (i.e. list of all the training images to be read at each epoch) at the beginning of each epoch.
Answered by today on August 30, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP