我正在使用tf.data.Dataset.map(process_fn)
指令,
映射函数由纯粹的 tensorflow 图函数组成,但 Autograph 似乎仍在尝试对其进行转换。我该如何预防?
如何强制 tensorflow 按原样使用我的代码段(定义图形)?
def process_fn(item):
assert 'image' in item
# this should be executed right not every time graph is executed
image = tf.image.convert_image_dtype(item.pop('image'), tf.float32)
image = tf.multiply(tf.subtract(image, 0.5), 2)
return image
出于某种原因,tensorflow 希望转换此函数并报告警告:这是不可能的,并且它将按原样使用。 问题是,为什么一开始就尝试使用 Autograph?
W0119 14:55:15.113813 140297917577024 ag_logging.py:146] Entity
<function geospatial_input.<locals>.process_fn at 0x7f991b5fe280> could
not be transformed and will be executed as-is. Please report this to
the AutoGraph team. When filing the bug, set the verbosity to 10 (on
Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
最佳答案
对于 v2.2(以及回到 v1.15),您可以使用 tf.autograph.experimental.do_not_convert :
@tf.autograph.experimental.do_not_convert
def process_fn(item):
...
关于tensorflow - 关闭 tensorflow 签名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59810774/