signed

QiShunwang

“诚信为本、客户至上”

使用Model.fit_generator时收到弃用警告: Model.fit_generator is deprecated and will be removed

2021/6/24 23:03:20   来源:

Tensorflow2.1版本以后在使用Model.fit_generator时收到了此弃用警告:

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.

在Tensorflow2.1及以后版本不再推荐fit_generator,使用Model.fit代替fit_generator即可。如何使用Model.fit代替Model.fit_generator?在Model.fit的第一个参数x可以使用生成器,因此只需x=generator即可。

可以在这里找到tf-2.1.0-rc1的文档:https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/keras/Model#fit