gpt4 book ai didi

tensorflow - 关闭 tensorflow 签名

转载 作者:行者123 更新时间:2023-12-04 10:43:48 24 4
gpt4 key购买 nike

我正在使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com