重定向python(tensorflow)警告消息(不禁止显示这些消息)?

时间:2020-07-16 22:04:02

标签: linux tensorflow

您好,以下是我的cmd,用于将消息重定向到/tmp/log.txt

!python models/ts_model/run.py \
    --name test > /tmp/log.txt

但是我仍然在控制台中看到很多以下警告消息(大多数来自Tensorflow,不确定是否相关)。

WARNING:tensorflow:Entity <bound method Dense.call of <tensorflow.python.layers.core.Dense object at 0x7f5e46ddfb70>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <bound method Dense.call of <tensorflow.python.layers.core.Dense object at 0x7f5e46ddfb70>>: AssertionError: Bad argument number for Name: 3, expecting 4

我尝试了不同的方法(也重定向了错误消息2> xxx.txt)。所有这些都不起作用。想知道有人给我建议吗?

1 个答案:

答案 0 :(得分:0)

在导入张量流之前先设置env变量

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

import tensorflow as tf

有关该环境变量的其他值的更多详细信息,请查看https://stackoverflow.com/a/42121886/1986981