简体   繁体   English

我怎么知道在tf.keras中实现了哪个版本的Keras API?

[英]How do I know which version of the Keras API is implemented in tf.keras?

In the standard implementation of Keras, one can get the API version using keras.__version__ . 在Keras的标准实现中,可以使用keras.__version__获得API版本。

However, there is no tf.keras.__version__ . 但是,没有tf.keras.__version__

So how do I check the version of the Keras API implemented in tf.keras ? 那么,如何检查tf.keras实现的tf.keras API版本?

You can simply run this code 您可以简单地运行此代码

from tensorflow.python import keras
print(keras.__version__)

which is compatible with TF v1.8.0. 与TF v1.8.0兼容。

You can retrieve the version of Keras implemented in tf.keras using 您可以使用以下命令检索在tf.keras实现的tf.keras版本

from tensorflow.python.keras._impl.keras import __version__ as tf_keras_version
print(tf_keras_version)
# 2.1.5-tf (in TF 1.8)

It seems that from TF 1.9 on, it will actually be accessible as tf.keras.__version__ , as it should. 似乎从TF 1.9开始,它实际上应该可以通过tf.keras.__version__进行访问。

This has recently been updated: 最近更新:

>>> import tensorflow as tf
>>> print(tf.keras.__version__)
2.1.6-tf
>>> print(tf.__version__)
1.12.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM