Had*_*ekh 11 tensorflow tensorflow2.0
我正在尝试在v2.0中运行一个tensorflow代码,并且遇到以下错误
AttributeError: module 'tensorflow' has no attribute 'logging'
Run Code Online (Sandbox Code Playgroud)
我不想简单地将其从代码中删除。
Had*_*ekh 18
tf.logging是用于Logging and Summary Operations并且在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
Run Code Online (Sandbox Code Playgroud)
或者如果你有 GPU:
pip install tensorflow-gpu==1.15.0
Run Code Online (Sandbox Code Playgroud)
您可能仍然会收到depricing警告,但是您不需要修改多个文件替换tf为tf.compat.v1