tensorflow - 关闭 tensorflow 签名

标签 tensorflow graph eager-execution

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

相关文章:

javascript - D3 : The data on the axis not mapping

algorithm - 最大限度地降低转型成本

python - 如何使用 tf.while_loop 进行急切执行?

python - TensorFlow 2.0 : Eager execution of training either returns bad results or doesn't learn at all

python - 没有名为 "data_utils"的模块...但已下载

javascript - 尝试将 TensorFlow 保存的模型转换为 TensorFlow.js 模型时出错

python - tf.train.shuffle_batch 和 `tf.train.batch 发生了什么?

Tensorflow:加载未知的 TFRecord 数据集

c - 无边的顶点总数 C

python - 热修复 Tensorflow 模型未使用 .fit() 在 Eager 模式下运行?