2016-06-28 55 views
8

Sto svincolando il mio codice Tensorflow con nosetest ma produce una tale quantità di output prolisso che lo rende inutile.Come sopprimere la registrazione dettagliata di Tensorflow?

il seguente test

import unittest 
import tensorflow as tf 

class MyTest(unittest.TestCase): 

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

quando eseguito con nosetests crea una quantità enorme di registrazione inutile:

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. 

...... 

mentre l'uso di tensorflow dalla console ipython non sembra che verbose:

$ 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]: 

Come è possibile eliminare la registrazione precedente durante l'esecuzione nosetests?

+0

Eventuali duplicati delle [informazioni Disabilita tensorflow debug] (http://stackoverflow.com/questions/35911252/disable-tensorflow-debugging-information) – craymichael

+0

Un'altra soluzione: https: //stackoverflow.com/questions/43337601/nosetests-with-tensorflow-lots-of-debugging-output-how-to-disable – vpekar

risposta

0

Ecco il numero an example di questo. Sfortunatamente ciò richiede la modifica dell'origine e della ricostruzione. Ecco un tracking bug per rendere più facile

18

1.0 Update (5/20/17):

In tensorflow 1.0, per questo issue, è ora possibile controllare la registrazione tramite la variabile d'ambiente chiamata TF_CPP_MIN_LOG_LEVEL; il valore predefinito è 0 (tutti i registri visualizzati), ma può essere impostato su 1 per filtrare i registri INFO, 2 per filtrare ulteriormente i registri WARNING e 3 per filtrare ulteriormente i registri ERROR. Vedere il seguente esempio generico sistema operativo utilizzando Python:

import os 
import tensorflow as tf 

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

per le versioni precedenti di tensorflow o TF-Learn registrazione, vedere il seguente:

Visualizzare la pagina qui sotto per informazioni sul disboscamento tensorflow; con il nuovo aggiornamento, è possibile impostare la verbosità di registrazione su DEBUG, INFO, WARN, ERROR o FATAL. Per esempio:

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

La pagina va aggiunta sulla monitor che possono essere utilizzati con i modelli TF-Learn. Here is the page.

Questo non blocca tutto il logging, sebbene (solo TF-Learn). Ho due soluzioni; una è una soluzione "tecnicamente corretta" (Linux) e l'altra riguarda la ricostruzione di TensorFlow.

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

Per l'altro, vedere this answer che comporta la modifica di origine e la ricostruzione tensorflow.