AttributeError: module 'tensorflow' has no attribute 'RunOptions'
AttributeError: module 'tensorflow' has no attribute 'RunOptions'
我是初学者。
我在 python IDLE 上使用 python - TensorFlow '2.2.0'。
run_opts = tf.RunOptions(report_tensor_allocations_upon_oom = True)
我在 运行 之前的代码中遇到了以下错误。:
AttributeError: module 'tensorflow' has no attribute 'RunOptions'"
然而,根据 Tensorflow 官方页面上 link 的示例 18,没有错误!
我的情况有什么问题?我该如何解决这个问题?
这是 tensorflow 1.x
和 tensorflow 2.x
之间的兼容性问题。换句话说,您编写的语法适用于 tensorflow 1.x
。但是正如您提到的,您使用的是不兼容的 tensorflow 2.2
。
所以,您可以通过以下两个选项之一来解决此问题:
卸载 tensorflow 2.2
并安装 tensorflow 1.15
知道您发布的 link 使用的是 [=16],这会让您省去很多麻烦=]如README file.
中所述
或者您可以使用 tf.compat.v1.RunOptions
而不是 tf.RunOptions
。
我是初学者。 我在 python IDLE 上使用 python - TensorFlow '2.2.0'。
run_opts = tf.RunOptions(report_tensor_allocations_upon_oom = True)
我在 运行 之前的代码中遇到了以下错误。:
AttributeError: module 'tensorflow' has no attribute 'RunOptions'"
然而,根据 Tensorflow 官方页面上 link 的示例 18,没有错误!
我的情况有什么问题?我该如何解决这个问题?
这是 tensorflow 1.x
和 tensorflow 2.x
之间的兼容性问题。换句话说,您编写的语法适用于 tensorflow 1.x
。但是正如您提到的,您使用的是不兼容的 tensorflow 2.2
。
所以,您可以通过以下两个选项之一来解决此问题:
卸载
tensorflow 2.2
并安装tensorflow 1.15
知道您发布的 link 使用的是 [=16],这会让您省去很多麻烦=]如README file. 中所述
或者您可以使用
tf.compat.v1.RunOptions
而不是tf.RunOptions
。