TF2 中的 Keras 实现是否支持原生 Keras 对 TF1 的所有操作?

Does the Keras implementation in TF2 support everything native Keras can do with TF1?

我们正在 TensorFlow 之上使用 Keras 1.x。但现在 TF 2.0 即将到来,我们正在考虑切换到该更新,使用 TF 2.0 中内置的 Keras API 实现。

但在我们这样做之前,我想问你们:你们知道 TF 2.0 中的 Keras 实现是否支持原生 Keras 对 TF 1.0 所做的一切,或者是否缺少任何功能?

此外,我能否将我的 Keras 代码 1:1 与 Keras API 的新 TF 2.0 实现一起使用,或者我们是否需要重写部分现有的 Keras 代码?

如果您想使用 TensorFlow,那么我强烈建议您切换并使用 Keras 的 TensorFlow 实现(即 tf.keras),因为它将支持 TF 的更多功能,并且效率更高,比原生 Keras 优化。

实际上,Keras 维护者几天前发布了 Keras 的新版本(2.2.5)(在 10 多个月没有新版本发布之后!),他们也推荐使用 tf.keras。这是 release notes:

Keras 2.2.5 is the last release of Keras that implements the 2.2.* API. It is the last release to only support TensorFlow 1 (as well as Theano and CNTK).

The next release will be 2.3.0, which makes significant API changes and add support for TensorFlow 2.0. The 2.3.0 release will be the last major release of multi-backend Keras. Multi-backend Keras is superseded by tf.keras.

At this time, we recommend that Keras users who use multi-backend Keras with the TensorFlow backend switch to tf.keras in TensorFlow 2.0. tf.keras is better maintained and has better integration with TensorFlow features.

这:“多后端 Keras 已被 tf.keras 取代”是一个强有力的指标,表明最好切换到 tf.keras,尤其是当您仍处于项目初期时。