Python ``tensorflow.get_logger()`` 获取日志记录器实例详解与示例


发布日期 : 2020-04-07 12:58:23 UTC

访问量: 10 次浏览

Python – tensorflow.get\_logger()

TensorFlow是谷歌设计的开源Python库,用于开发机器学习模型和深度学习神经网络。

get_logger()用于获取记录器实例。

语法:
tensorflow.get_logger()

参数:它不接受任何参数。

返回:它返回记录器实例。

示例 1:

# Importing the library
import tensorflow as tf

# Fetting logger instance 
logger = tf.get_logger()

# Checking if propagation is enabled
res = logger.propagate

# Printing the result
print('res: ',res)

输出:

res: True

示例 2:

# Importing the library
import tensorflow as tf

# Fetting logger instance 
logger = tf.get_logger()

# Disabling the propagation
logger.propagate = False

# Checking if propagation is enabled
res = logger.propagate

# Printing the result
print('res: ',res)

输出:

```
res: False