Skip to content
Advertisement

How to use Model.fit which supports generators (after fit_generator deprecation)

I have got this deprecation warning while using Model.fit_generator in tensorflow:

WARNING:tensorflow: Model.fit_generator (from tensorflow.python.keras.engine.training) is deprecated and will be removed in a future version.
Instructions for updating:
Please use Model.fit, which supports generators.

How can I use Model.fit instead of Model.fit_generator?

Advertisement

Answer

Model.fit_generator is deprecated starting from tensorflow 2.1.0 which is currently is in rc1. You can find the documentation for tf-2.1.0-rc1 here: https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/keras/Model#fit

As you can see the first argument of the Model.fit can take a generator so just pass it your generator.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement