问题和标题所述相同。
我更喜欢不打开Python,而是使用MacOS或Ubuntu。
Python库的作者将版本号放在<module>.__version__
中。您可以通过在命令行上运行以下内容来打印它:
print(<module>.__version__)
python -c 'import keras; print(keras.__version__)'
如果是Windows终端,请像下面这样使用双引号将代码片段括起来
python -c "import keras; print(keras.__version__)"
您可以写:
python
import keras
keras.__version__
最简单的方法是使用pip
命令:
pip list | grep Keras
检查 Keras 版本的简单命令:
(py36) C:\WINDOWS\system32>python
Python 3.6.8 |Anaconda custom (64-bit)
>>> import keras
Using TensorFlow backend.
>>> keras.__version__
'2.2.4'
pip show tensorflow
C:\>pip show tensorflow
Name: tensorflow
Version: 2.4.1
Summary: TensorFlow is an open source machine learning framework for
everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Requires: google-pasta, wheel, absl-py, flatbuffers, numpy, astunparse, opt-
einsum, six, termcolor, typing-extensions, wrapt, grpcio, tensorboard,
protobuf, tensorflow-estimator, gast, h5py, keras-preprocessing
Required-by:
同样的方法可以尝试一下:
pip show keras
对于终端,运行以下命令:(如果使用 Python3
版本,请将 "python" 替换为 "python3")
python -c 'import keras; print(keras.__version__)'
如果您想检查代码内部,请包含以下内容:
import keras
print(keras.__version__)
pip install keras
),那么很简单:import keras
print(keras.__version__)
import keras_core as keras
print(keras.__version__)
pip install tensorflow
)——那么Keras API的版本取决于TensorFlow的版本。你可以尝试这样做:import tensorflow as tf
print(tf.keras.__version__) # works for TF version 1.9 to 2.13
tf.keras.__version__
未定义。tf.__version__ |
tf.keras.__version__ |
---|---|
≤1.8.* | 未定义 |
1.9.* | 2.1.6-tf |
1.10.* | 2.1.6-tf |
1.11.* | 2.1.6-tf |
1.12.* | 2.1.6-tf |
1.13.* | 2.2.4-tf |
1.14.* | 2.3.0-tf(如果tf2.enabled(),否则2.2.4-tf) |
1.15.* | 2.3.0-tf(如果tf2.enabled(),否则2.2.4-tf) |
2.0.* | 2.3.0-tf(如果tf2.enabled(),否则2.2.4-tf) |
2.1.* | 2.3.0-tf(如果tf2.enabled(),否则2.2.4-tf) |
2.2.* | 2.3.0-tf(如果tf2.enabled(),否则2.2.4-tf) |
2.3.* | 2.4.0 |
2.4.* | 2.4.0 |
2.5.* | 2.5.0 |
2.6.* | 2.6.0 |
2.7.* | 2.6.0 |
2.8.* | 2.6.0 |
2.9.* | 2.6.0 |
2.10.* | 2.6.0 |
2.11.* | 2.6.0 |
2.12.* | 2.6.0 |
2.13.* | 2.6.0 |
2.14.* | 未定义 |
2.15.* | 未定义 |
python3 -c 'import keras; print(keras.__version__)'
- Akash Kandpal