硬对比tensorflow.keras

keras vs. tensorflow.keras

受此启发

为什么这两个模块有区别?

我什么时候会用一个代替另一个?

还有什么我应该知道的吗?

Keras 是一个独立的 high-level API,支持 TensorFlow、Theano 和 CNTK 后端。现在,Theano 和 CNTK 已经停止开发了。

tf.keras 是集成到 TensorFlow 2 中的 Keras API。

因此,如果您打算使用 TensorFlow 作为深度学习框架,我建议您使用 tensorflow.keras 来减少头痛。

同样基于 Keras 的创建者 François Chollet 的 tweet

We recommend you switch your Keras code to tf.keras.

Both Theano and CNTK are out of development. Meanwhile, as Keras backends, they represent less than 4% of Keras usage. The other 96% of users (of which more than half are already on tf.keras) are better served with tf.keras.

Keras development will focus on tf.keras going forward.

Importantly, we will seek to start developing tf.keras in its own standalone GitHub repository at keras-team/keras in order to make it much easier for 3rd party folks to contribute.