tensorflow log messages ---- tf.logging

1. tensorflow log Introduction

TensorFlow use five different levels of log messages. Ascending order, they are DEBUG, INFO, WARN, ERRORand FATAL. When you record at any of these levels configuration log, TensorFlow output all log messages corresponding to the level greater than that level and all log. For example, if the ERROR logging level is set, and you will receive a log output and a FATAL ERROR message contains, if a set DEBUG level, will obtain all log messages from the five levels. By default, Tensorflow in the WARN logging level configuration, but when tracking model training, you need to adjust the level INFO, which will provide feedback for other operations in progress.

2. tf.logging.set_verbosity()

Setting a threshold for which log messages will be recorded. Python log corresponding to levelthe parameter

# 设置日志级别,此时显示大于等于INFO级别的日志
tf.logging.set_verbosity(tf.logging.INFO)

3. Logging

tf.logging.info("hellow,word")              # 记录一条info级别的日志
tf.logging.debug("hellow,word")
tf.logging.warn("helllow, word")
tf.logging.error("hellow, word")
tf.logging.fatal("hellow, word")

Example 4

Under 4.1 default default, Tensorflow be configured WARN logging level

import tensorflow as tf
tf.logging.info("hellow word, info level")
tf.logging.debug("hellow word, debug level")
tf.logging.warn("hellow word, warn level")
tf.logging.error("hellow word, error level")
tf.logging.fatal("hellow word, fatal level")

Export

W0208 12:12:14.905251 90696 test.py:5] hellow word, warn level
E0208 12:12:14.905251 90696 test.py:6] hellow word, error level
E0208 12:12:14.906248 90696 test.py:7] CRITICAL - hellow word, fatal level
[Finished in 49.2s]

4.2 Setting level logging

Info output level greater than or equal to log

import tensorflow as tf
tf.logging.set_verbosity(tf.logging.INFO)
tf.logging.info("hellow word, info level")
tf.logging.debug("hellow word, debug level")
tf.logging.warn("hellow word, warn level")
tf.logging.error("hellow word, error level")
tf.logging.fatal("hellow word, fatal level")

Export

I0208 12:15:57.261396 69356 test.py:3] hellow word, info level
W0208 12:15:57.261396 69356 test.py:5] hellow word, warn level
E0208 12:15:57.261396 69356 test.py:6] hellow word, error level
E0208 12:15:57.261396 69356 test.py:7] CRITICAL - hellow word, fatal level

5. Other matters

5.1 tf.logging.info(msg, *args, **args)

Parameter argsis with msg placeholder used, such as

tf.logging.info("now %d epochs on %s ", 100, "test.py")

Export

I0208 12:36:35.534926 86200 test.py:3] now 100 epochs on test.py 
Published 33 original articles · won praise 1 · views 2608

Guess you like

Origin blog.csdn.net/orangerfun/article/details/104220977