gpt4 book ai didi

tensorflow - Tensorflow 2 中的急切执行

转载 作者:行者123 更新时间:2023-12-03 19:30:52 25 4
gpt4 key购买 nike

我正在 Google Colab 上测试代码。似乎 Google Colab 默认运行的是 Tensorflow 的第 2 版:

[In:]
import tensorflow as tf
print(tf.__version__)

[Out:]
2.0.0-dev20190130

并且这个版本没有急切执行:
[In:]
tf.enable_eager_execution()

[Out:]
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-ddf3115bdcc7> in <module>()
----> 1 tf.enable_eager_execution()

AttributeError: module 'tensorflow' has no attribute 'enable_eager_execution'

我找不到有关 TensorFlow 2 的文档。我也无法运行旧版本的 TensorFlow:
[In:]
!pip install tensorflow==1.12.0
import tensorflow as tf
print(tf.__version__)

[Out:]
Requirement already satisfied: tensorflow==1.12.0 in /usr/local/lib/python3.6/dist-packages (1.12.0)
Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (1.11.0)
Requirement already satisfied: absl-py>=0.1.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (0.7.0)
Requirement already satisfied: astor>=0.6.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (0.7.1)
Requirement already satisfied: protobuf>=3.6.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (3.6.1)
Requirement already satisfied: gast>=0.2.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (0.2.2)
Requirement already satisfied: tensorboard<1.13.0,>=1.12.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (1.12.2)
Requirement already satisfied: wheel>=0.26 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (0.32.3)
Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (1.0.5)
Requirement already satisfied: grpcio>=1.8.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (1.15.0)
Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (1.1.0)
Requirement already satisfied: keras-applications>=1.0.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (1.0.6)
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.12.0) (1.14.6)
Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from protobuf>=3.6.1->tensorflow==1.12.0) (40.7.0)
Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.6/dist-packages (from tensorboard<1.13.0,>=1.12.0->tensorflow==1.12.0) (3.0.1)
Requirement already satisfied: werkzeug>=0.11.10 in /usr/local/lib/python3.6/dist-packages (from tensorboard<1.13.0,>=1.12.0->tensorflow==1.12.0) (0.14.1)
Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from keras-applications>=1.0.6->tensorflow==1.12.0) (2.8.0)
2.0.0-dev20190130

this thread从 5 个月前开始表明我们不能降级 Tensorflow 版本。

是否可以在 Google Colab 上启用 Eager Execution?

最佳答案

在 TensorFlow 2.0 中,默认启用 Eager 执行。无需设置。

关于tensorflow - Tensorflow 2 中的急切执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54440859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com