How to use model.fit() which supports generators (because fit_generator() is deprecated)?
Let’s solve this issue…
I have personally got this deprecation warning while using model.fit_generator()
in TensorFlow like below.
You can see in the above image that the system recommend us to use Model.fit
instead Model.fit_generator
, right.
So, the question is How can we use Model.fit()
?
In the above image, I have marked a word generator
. The above image is the reference from the official Tensorflow documentation where it is mentioned that we can use the generator in the fit method.
You can use Model.fit()
like below.
Note:
We can’t use
validation_split
when our dataset isgenerator
orkeras.utils.Sequence
in thefit()
method.Now, we can use
validation_split
inflow_from_directory()
.
Let’s start
- See my dataset directory
2. Split your dataset into logical train
and validation
dataset. like below…
Note:
dir_path
in the above image is the path of my complete dataset.
3. Use Model.fit()
I do hope that it will help you to understand Model.fit()
.
If you liked it, please clap and SUBSCRIBE my YOUTUBE channel. Thanks!