yongyong-e

[TensorFlow] 로그 필터링 본문

머신러닝/TensorFlow

[TensorFlow] 로그 필터링

Yonghan Kim 2018. 6. 30. 22:56

Tensorflow는 TF_CPP_MIN_LOG_LEVEL 이라는 환경 변수를 통해 로깅을 제어 할 수 있다. 

기본값은 0 (모든 로그가 표시됨)이지만 INFO 로그를 필터링하려면 1, WARNING 로그를 필터링하려면 2, ERROR 로그를 추가로 필터링하려면 3으로 설정할 수 있다.


기본적으로 Tensorflow 코드를 컴파일하면 아래와 같은 로그를 볼 수 있다.

1
2
3
4
5
6
7
8
import tensorflow as tf
 
hello = tf.constant('Hello, TensorFlow!')
print(hello)
 
with tf.Session() as sess:
    print(sess.run(hello))
    sess.close()
cs

>> Tensor("Const:0", shape=(), dtype=string) 

2018-06-30 22:45:03.704720: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 

b'Hello, TensorFlow!'


아래는 TF_CPP_MIN_LOG_LEVEL=2로 환경변수를 설정을 통해 Tensorflow의 WARNING 로그가 필터링 되는 것을 볼 수 있다.
1
2
3
4
5
6
7
8
9
10
11
import os
import tensorflow as tf
 
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
 
hello = tf.constant('Hello, TensorFlow!')
print(hello)
 
with tf.Session() as sess:
    print(sess.run(hello))
    sess.close()
cs

>> Tensor("Const:0", shape=(), dtype=string) 

b'Hello, TensorFlow!'


'머신러닝 > TensorFlow' 카테고리의 다른 글

[TensorFlow] Softmax Classification  (0) 2018.07.02
[TensorFlow] Flags  (0) 2018.06.30
[TensorFlow] Tensor  (0) 2018.06.22
[TensorFlow] Tested source configurations  (0) 2017.11.23
[TensorFlow] Linear Regression  (0) 2017.09.11
Comments