python3 识别 tensorflow,但不识别其任何属性

Jel*_* Wu 8 attributeerror tensorflow

python3 无法识别任何 tensorflow 属性

AttributeError: 模块“tensorflow”没有属性“variable_scope”

AttributeError: 模块“tensorflow”没有属性“squared_difference”

已安装张量流

pip3 列表 | grep tensorflow tensorflow 2.0.0
tensorflow-estimator 2.0.1

Dji*_*011 12

TensorFlow 2.0 清理了一些 API。诸如squared_difference()现在的数学函数tf.math

tf.variable_scope()TensorFlow 2.0 中没有。我建议阅读这篇文章,其中包含有关如何将代码迁移到 TF2 的示例。

如果您希望您的代码与旧版本的 TensorFlow 兼容,您可以使用 tf.compat.v1.variable_scope()