标题说明了一切。我正在使用Ubuntu 16.04长期支持。
答案 0 :(得分:280)
这取决于您安装TensorFlow的方式。我将使用TensorFlow's installation instructions使用的相同标题来构建此答案。
执行命令
python -c 'import tensorflow as tf; print(tf.__version__)' # for Python 2
python3 -c 'import tensorflow as tf; print(tf.__version__)' # for Python 3
请注意,python
在某些Linux发行版中与/usr/bin/python3
符号链接,因此在这些情况下请使用python
代替python3
。
pip list | grep tensorflow
或Python 3的pip3 list | grep tensorflow
也将显示已安装的Tensorflow版本。
执行命令
python -c 'import tensorflow as tf; print(tf.__version__)' # for both Python 2 and Python 3
pip list | grep tensorflow
还会显示安装的Tensorflow版本。
例如,我在Python 3的virtualenv
中安装了TensorFlow 0.9.0。所以,我得到:
$ python -c 'import tensorflow as tf; print(tf.__version__)'
0.9.0
$ pip list | grep tensorflow
tensorflow (0.9.0)
答案 1 :(得分:48)
python中的几乎每个普通包都会将变量.__version__
或VERSION
分配给当前版本。因此,如果您想查找某个软件包的版本,可以执行以下操作
import a
a.__version__ # or a.VERSION
对于张量流,它将是
import tensorflow as tf
tf.VERSION
对于旧版本的tensorflow(低于0.10),请使用tf.__version__
BTW,如果您打算安装tf,install it with conda, not pip
答案 2 :(得分:24)
import tensorflow as tf
print tf.VERSION
答案 3 :(得分:13)
如果您已通过pip安装,请运行以下
block_id
答案 4 :(得分:8)
如果您正在使用anaconda分发的Python,
df['C'] = np.select([ df.A > df.B ], ['yes'], default='IGNORE')
df = df.drop(df[(df.C == 'IGNORE')].index)
使用Jupyter Notebook(IPython Notebook)检查它
$ conda list | grep tensorflow
tensorflow 1.0.0 py35_0 conda-forge
答案 5 :(得分:7)
对于python 3.6.2:
import tensorflow as tf
print(tf.VERSION)
答案 6 :(得分:6)
要了解python库的任何版本,然后使用pip安装您的库,请使用以下命令。
pip show tensorflow
以上命令的输出如下所示:-
Name: tensorflow
Version: 2.3.0
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
Location: /usr/local/lib/python3.6/dist-packages
Requires: astunparse, wheel, keras-preprocessing, gast, tensorflow-estimator, opt-einsum, tensorboard, protobuf, absl-py, six, wrapt, termcolor, numpy, grpcio, scipy, google-pasta, h5py
Required-by: fancyimpute
答案 7 :(得分:5)
我从源代码安装了Tensorflow 0.12rc,以下命令为我提供了版本信息:
python -c 'import tensorflow as tf; print(tf.__version__)' # for Python 2
python3 -c 'import tensorflow as tf; print(tf.__version__)' # for Python 3
下图显示了输出:
答案 8 :(得分:3)
要获得有关tensorflow及其选项的更多信息,您可以使用以下命令:
>> import tensorflow as tf
>> help(tf)
答案 9 :(得分:2)
在最新的TensorFlow版本上 1.14.0
tf.VERSION
已弃用,而不是
tf.version.VERSION
错误:
WARNING: Logging before flag parsing goes to stderr.
The name tf.VERSION is deprecated. Please use tf.version.VERSION instead.
答案 10 :(得分:1)
python -c 'import tensorflow as tf; print(tf.__version__)' # for Python 2
python3 -c 'import tensorflow as tf; print(tf.__version__)' # for Python 3
这里-c表示以字符串形式传入的程序(终止选项列表)
答案 11 :(得分:1)
tensorflow版本可以在终端或控制台上检查,也可以在任何IDE编辑器中检查(例如Spyder或Jupyter笔记本电脑等)
用于检查版本的简单命令:
(py36) C:\WINDOWS\system32>python
Python 3.6.8 |Anaconda custom (64-bit)
>>> import tensorflow as tf
>>> tf.__version__
'1.13.1'
答案 12 :(得分:1)
如果您具有TensorFlow 2.x:
sess = tf.compat.v1.Session(config = tf.compat.v1.ConfigProto(log_device_placement = True))
答案 13 :(得分:0)
轻松获得KERAS和TENSORFLOW版本号-> 在终端中运行以下命令:
[username @ usrnm:〜] python3
>>import keras; print(keras.__version__)
Using TensorFlow backend.
2.2.4
>>import tensorflow as tf; print(tf.__version__)
1.12.0
答案 14 :(得分:0)
Jupyter Notebook中的Tensorflow版本:-
!pip list | grep tensorflow
答案 15 :(得分:0)
另一种变化,我想:P
python3 -c 'print(__import__("tensorflow").__version__)'
答案 16 :(得分:-4)
对于Python 3.6.3:
import tensorflow as tf
print(tf.VERSION)