使用tensorflow对象检测api时如何防止每一步打印丢失?

How to prevent printing loss at each step while using the tensorflow object detection api?

我正在 Google Colab 中使用 Tensorflow 对象检测 API 进行训练。我想抑制打印每一步的损失,因为网页在 30 分钟后崩溃,因为大量文本被打印为单元格的输出。我必须每 30 分钟左右手动清除单元格的输出以避免此问题。有什么方法可以修改 train.py 代码,使 Tensorflow 停止在每一步打印损失。我曾尝试将 research/object_detection/legacy/train.py 的第 57 行中的代码从 tf.logging.set_verbosity(tf.logging.INFO) 更改为 tf.logging.set_verbosity(tf.logging.WARN) 但它似乎不起作用。任何 suggestions/workarounds?

添加; if that's the print statement at the end of print statement

在单元格的第一行添加%%capture为单元格不打印

和特定功能

from IPython.utils import io

with io.capture_output() as captured: function()