2016-06-28 24 views
8

私はnosetestsで自分のTensorflowコードをユニットテストしていますが、そのような量の冗長な出力が生成され、無駄になります。詳細なTensorflowロギングを抑制する方法は?

FAIL: test_creation (tests.test_tf.MyTest) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "/home/cebrian/GIT/thesis-nilm/code/deepmodels/tests/test_tf.py", line 10, in test_creation 
    self.assertEquals(True, False) 
AssertionError: True != False 
-------------------- >> begin captured logging << -------------------- 
tensorflow: Level 1: Registering Const (<function _ConstantShape at 0x7f4379131c80>) in shape functions. 
tensorflow: Level 1: Registering Assert (<function no_outputs at 0x7f43791319b0>) in shape functions. 
tensorflow: Level 1: Registering Print (<function _PrintGrad at 0x7f4378effd70>) in gradient. 
tensorflow: Level 1: Registering Print (<function unchanged_shape at 0x7f4379131320>) in shape functions. 
tensorflow: Level 1: Registering HistogramAccumulatorSummary (None) in gradient. 
tensorflow: Level 1: Registering HistogramSummary (None) in gradient. 
tensorflow: Level 1: Registering ImageSummary (None) in gradient. 
tensorflow: Level 1: Registering AudioSummary (None) in gradient. 
tensorflow: Level 1: Registering MergeSummary (None) in gradient. 
tensorflow: Level 1: Registering ScalarSummary (None) in gradient. 
tensorflow: Level 1: Registering ScalarSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering MergeSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering AudioSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering ImageSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering HistogramSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering HistogramAccumulatorSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering Pack (<function _PackShape at 0x7f4378f047d0>) in shape functions. 
tensorflow: Level 1: Registering Unpack (<function _UnpackShape at 0x7f4378f048c0>) in shape functions. 
tensorflow: Level 1: Registering Concat (<function _ConcatShape at 0x7f4378f04938>) in shape functions. 
tensorflow: Level 1: Registering ConcatOffset (<function _ConcatOffsetShape at 0x7f4378f049b0>) in shape functions. 

...... 

ipythonコンソールからtensorflowを使用して、一方、冗長なことに思われない:

nosetestsで実行し、次のテスト

import unittest 
import tensorflow as tf 

class MyTest(unittest.TestCase): 

    def test_creation(self): 
     self.assertEquals(True, False) 

は無用ログの膨大な量を作成し、

$ ipython 
Python 2.7.11+ (default, Apr 17 2016, 14:00:29) 
Type "copyright", "credits" or "license" for more information. 

IPython 4.2.0 -- An enhanced Interactive Python. 
?   -> Introduction and overview of IPython's features. 
%quickref -> Quick reference. 
help  -> Python's own help system. 
object? -> Details about 'object', use 'object??' for extra details. 

In [1]: import tensorflow as tf 
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally 
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally 
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally 
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so locally 
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally 

In [2]: 

実行時に以前のログを抑制する方法nosetests?

+0

の可能性のある重複した[無効Tensorflowデバッグ情報](http://stackoverflow.com/questions/35911252/disable-tensorflow-debugging-information) – craymichael

+0

別の解決策ます。https: //stackoverflow.com/questions/43337601/nosetests-with-tensorflow-lots-of-debugging-output-how-to-disable – vpekar

答えて

0

これは、an exampleです。残念ながら、これにはソースの変更と再構築が必要です。ここtracking bugは作ることだ、それより簡単

18

1.0アップデート(5/20/17):

TensorFlow 1.0では、このissueごとに、あなたが今TF_CPP_MIN_LOG_LEVELと呼ばれる環境変数を経由してログを制御することができます。デフォルトでは0(すべてのログが表示されます)が設定されますが、ログにはINFOログを除外するために1、ログにはさらにWARNINGのログを除外するために2、さらにログにはERRORを除外するために3に設定できます。パイソンを使用して、次の一般的なOSの例を参照してください。

import os 
import tensorflow as tf 

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' 

前TensorFlowのバージョンまたはTF-学びログについては、以下を参照してください。

はTensorFlowログの詳細については、下のページを表示します。新しいアップデートでは、ログの冗長性をDEBUG,INFOWARNERROR、またはFATALのいずれかに設定できます。例:

tf.logging.set_verbosity(tf.logging.ERROR) 

さらに、ページはTF-Learnモデルで使用できるモニターを超えています。 Here is the page

はすべてのログをブロックしません(TF-Learnのみ)。私には2つの解決策があります。 1つは「技術的に正しい」ソリューション(Linux)で、もう1つはTensorFlowを再構築することです。その他については

script -c 'python [FILENAME].py' | grep -v 'I tensorflow/' 

、ソースを変更し、TensorFlowを再構築する必要どのthis answerを参照してください。

関連する問題