如何抑制"WARNING:tensorflow:AutoGraph could not transform <bound method Layer.__call__ of ... >>



每次运行tf.keras.Sequential().predict_on_batch:

时都会得到此消息
WARNING: AutoGraph could not transform <bound method Layer.__call__ of <tensorflow.python.keras.engine.sequential.Sequential object at 0x000001F927581348>> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause: 

它完全填满了我的控制台,我找不到一种方法来抑制它。

Python版本:3.7.7Tensorflow版本:2.1.0

我在带有for循环的自定义图层中遇到过这种情况。我一直在用@tf.autograph.experimental.do_not_convert修饰调用方法

例如:

class DoNothing(tf.keras.layers.Layer):
def __init__(self, **kwargs):
super().__init__(**kwargs)

def get_config(self):
config = {}
base_config = super().get_config()
return {**base_config, **config}
@tf.autograph.experimental.do_not_convert
def call(self, args, **kwargs):
return args # Yes, this layer really doesn't do anything 

使用下面的代码

设置签名的冗长程度
import os
import tensorflow as tf
os.environ['AUTOGRAPH_VERBOSITY'] = 1

您可以通过在程序开始时设置日志级别来抑制警告

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' 
import tensorflow as tf

相关内容

  • 没有找到相关文章

最新更新