1通过设置环境变量"TF_CPP_MIN_LOG_LEVEL"控制log级别
Level | Level for Humans | Level Description |
---|---|---|
0 | DEBUG | all messages are logged (Default) |
1 | INFO | INFO messages are not printed |
2 | WARNING | INFO and WARNING messages are not printed |
3 | ERROR | INFO, WARNING, and ERROR messages are not printed |
2设置
-
永久设置:加入环境变量TF_CPP_MIN_LOG_LEVEL=1
-
临时设置:os.environ[‘TF_CPP_MIN_LOG_LEVEL‘]=‘1‘
3通过 tf.logging 模块进行设置 – 推荐
-
tf.logging.set_verbosity(tf.logging.ERROR)
-
tf.logging.ERROR可以换成 {DEBUG, INFO, WARN, ERROR, FATAL} 中的任何一个。
4举例
import os
import sys
# Stop TF from showing unnecessary deprecation warnings
import warnings
warnings.filterwarnings('ignore')
from tensorflow import logging
logging.set_verbosity(logging.ERROR)
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
点赞,关注,收藏👍,➕,👀点赞,关注,收藏👍,➕,👀点赞,关注,收藏👍,➕,👀
😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘
💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪💪