代码测试环境 : CPU 环境的 TensorFlow
一. 默认 Log 配置
# coding:utf-8
import tensorflow as tf
def test0():
v = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
sess = tf.Session()
with sess.as_default():
print(tf.clip_by_value(v, 3, 5).eval())
def main():
print('start.')
test0()
print('end.')
if __name__ == '__main__':
main()
输出为 :
start.
2017-10-17 21:20:34.570991: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-10-17 21:20:34.571017: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-10-17 21:20:34.571023: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-10-17 21:20:34.571027: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
[[ 3. 3. 3.]
[ 4. 5. 5.]]
end.
二. 指定 Log 配置
添加如下代码 :
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
start.
[[ 3. 3. 3.]
[ 4. 5. 5.]]
end.
三. LOG 等级说明
import os
os.environ[‘TF_CPP_MIN_LOG_LEVEL‘]=‘1‘ # 这是默认的显示等级,显示所有信息
# 2级
import os
os.environ[‘TF_CPP_MIN_LOG_LEVEL‘]=‘2‘ # 只显示 warning 和 Error
# 3级
import os
os.environ[‘TF_CPP_MIN_LOG_LEVEL‘]=‘3‘ # 只显示 Error