nosetests with tensorflow:大量的调试输出,如何禁用

Alb*_*ert 8 unit-testing nose tensorflow

当我使用nosetestsTensorFlow的一些测试脚本时,我从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 << ---------------------

----------------------------------------------------------------------
...
Run Code Online (Sandbox Code Playgroud)

来自TensorFlow的详细调试输出在某些情况下可能很有用,但很可能不适用于我的情况,或者至少绝对不是这个特定文件中的测试.

我怎样才能禁用它们?

Alb*_*ert 15

我现在正在这样做:

import logging
logging.getLogger('tensorflow').disabled = True
Run Code Online (Sandbox Code Playgroud)


pet*_*rux 6

你可以试试nosetests tests/test_TFUtil.py --nologcapture.

PS你能不能从测试文件中发布一些代码?谢谢.