11

I've installed tensorflow 2.0.0-alpha0. When trying to set logging verbosity with the tf.logging.set_verbosity(tf.logging.ERROR) command, I got the following error:

module 'tensorflow' has no attribute 'logging'.

Are there some changes with this point in the 2.0.0-alpha0 version?

4

2 回答 2

16

TensorFlow 2.0您仍然可以通过以下tf.logging方式访问tf.compat.v1

tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

编辑

这里,在Deprecated namespaces中,建议使用 Pythonlogging模块:

tf.logging -logging可以使用 Python 模块。

所以你应该使用:

import logging
logging.getLogger("tensorflow").setLevel(logging.ERROR)

导入前tensorflow

于 2019-03-10T09:09:28.593 回答
2

根据官方文档

许多 API 在 TF 2.0 中要么消失要么移动。一些主要更改包括删除 tf.app、tf.flags 和 tf.logging

https://www.tensorflow.org/alpha/guide/effective_tf2

于 2019-03-09T21:26:14.483 回答