Unit testing tensorflow测试:大量调试输出,如何禁用

Unit testing tensorflow测试:大量调试输出,如何禁用,unit-testing,tensorflow,nose,Unit Testing,Tensorflow,Nose,当我将nosetests与TensorFlow的一些测试脚本一起使用时,我从TensorFlow获得了大量调试输出: az@azmacbookpro ~/P/crnn> nosetests tests/test_TFUtil.py Level 1:tensorflow:Registering FakeQuantWithMinMaxArgs (<function _FakeQuantWithMinMaxArgsGradient at 0x112306048>) in gradi

当我将
nosetests
与TensorFlow的一些测试脚本一起使用时,我从TensorFlow获得了大量调试输出:

az@azmacbookpro ~/P/crnn> nosetests tests/test_TFUtil.py 
Level 1:tensorflow:Registering FakeQuantWithMinMaxArgs (<function _FakeQuantWithMinMaxArgsGradient at 0x112306048>) in gradient.
Level 1:tensorflow:Registering FakeQuantWithMinMaxVars (<function _FakeQuantWithMinMaxVarsGradient at 0x1126ba9d8>) in gradient.
Level 1:tensorflow:Registering FakeQuantWithMinMaxVarsPerChannel (<function _FakeQuantWithMinMaxVarsPerChannelGradient at 0x1126ba950>) in gradient.
...
Level 1:tensorflow:Registering Fact (<function _set_call_cpp_shape_fn.<locals>.call_without_requiring at 0x1122c0268>) in default shape functions.
Level 1:tensorflow:Registering TensorSummary (None) in gradient.
Level 1:tensorflow:Registering queue_runners ((<class 'tensorflow.core.protobuf.queue_runner_pb2.QueueRunnerDef'>, <function QueueRunner.to_proto at 0x1130687b8>, <function QueueRunner.from_proto at 0x113068840>)) in proto functions.
E
======================================================================
...
-------------------- >> begin captured logging << --------------------
tensorflow: Level 1: Registering FakeQuantWithMinMaxArgs (<function _FakeQuantWithMinMaxArgsGradient at 0x112306048>) in gradient.
tensorflow: Level 1: Registering FakeQuantWithMinMaxVars (<function _FakeQuantWithMinMaxVarsGradient at 0x1126ba9d8>) in gradient.
tensorflow: Level 1: Registering FakeQuantWithMinMaxVarsPerChannel (<function _FakeQuantWithMinMaxVarsPerChannelGradient at 0x1126ba950>) in gradient.
...
tensorflow: Level 1: Registering queue_runners ((<class 'tensorflow.core.protobuf.queue_runner_pb2.QueueRunnerDef'>, <function QueueRunner.to_proto at 0x1130687b8>, <function QueueRunner.from_proto at 0x113068840>)) in proto functions.
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
...
az@azmacbookpro~/P/crnn>nosetests/test\u TFUtil.py
级别1:tensorflow:在渐变中注册FakeQuantWithMinMaxArgs()。
级别1:tensorflow:在渐变中注册FakeQuantWithMinMaxVars()。
级别1:tensorflow:在渐变中注册FakeQuantWithMinMaxVarsPerChannel()。
...
级别1:tensorflow:在默认形状函数中注册事实()。
级别1:tensorflow:在渐变中注册TensorSummary(无)。
级别1:tensorflow:在proto函数中注册队列运行程序((,))。
E
======================================================================
...

-------------------->>开始捕获日志>结束捕获日志您可以尝试使用
nosetests测试/test\u TFUtil.py--nologcapture

另外,你能从测试文件中发布一些代码吗?谢谢。

我现在正在做:

import logging
logging.getLogger('tensorflow').disabled = True

如果文件仅包含单行
import tensorflow
,则会发生这种情况。我是否可以直接在文件中设置此
--nologcapture
?黑客可能是
sys.args+=['--nologcapture']
,但不确定这是否有效。我认为在
sys.arg
中添加参数不可行。从一般的角度来看,由于此设置与nose相关,我将使用命令行选项将其保留在代码之外——如果您运行一个普通的
python-m unittest mytest.py
您不会看到任何转储。