【问题标题】:nosetests with tensorflow: lots of debugging output, how to disable带有张量流的鼻子测试:大量调试输出,如何禁用
【发布时间】:2017-09-06 08:22:53
【问题描述】:

当我将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 << ---------------------

----------------------------------------------------------------------
...

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

如何禁用它们?

【问题讨论】:

    标签: unit-testing tensorflow nose


    【解决方案1】:

    我现在正在这样做:

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

    【讨论】:

      【解决方案2】:

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

      附:你能从测试文件中发布一些代码吗?谢谢。

      【讨论】:

      • 如果文件只包含一行import tensorflow,就会发生这种情况。我也可以直接在文件中设置这个--nologcapture 吗? hack 将是 sys.args += ['--nologcapture'] 但不确定是否有效。
      • 我认为向sys.arg 添加参数是行不通的。从一般的角度来看,由于此设置与鼻子有关,我会使用命令行选项将其保留在代码之外——如果你运行一个普通的python -m unittest mytest.py,你看不到任何转储。跨度>
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-03
      • 1970-01-01
      • 1970-01-01
      • 2017-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多