我正在尝试在 v2.0 中运行 tensorflow 代码,但出现以下错误
AttributeError: module 'tensorflow' has no attribute 'logging'
我不想简单地从代码中删除它。
- 为什么此代码已被删除?
- 我为什么要这样做?
我正在尝试在 v2.0 中运行 tensorflow 代码,但出现以下错误
AttributeError: module 'tensorflow' has no attribute 'logging'
我不想简单地从代码中删除它。
tf.logging 适用Logging and Summary Operations
于 TF 2.0,在 TF 2.0 中它已被删除,以支持开源 absl-py,并使主 tf.* 命名空间具有将更频繁使用的功能。
在 TF.2 中,较少使用的函数已消失或移至 tf.math 等子包中
因此,您可以代替 tf.logging:
tf_upgrade_v2
将升级脚本和更改tf.logging
为tf.compat.v1.logging
如果您使用的是其他人的代码,最好安装与作者使用相同的 Tensorflow 版本,或者降级您的 Tensorflow 版本。你可能想试试这个:
pip install tensorflow==1.15.0
或者如果你有 gpu:
pip install tensorflow-gpu==1.15.0
您可能仍然会收到贬低的警告,但是您不需要修改多个文件替换tf
为tf.compat.v1