2

I'm using tf.data.Dataset.map(process_fn) instruction, the mapping function is composed purely tensorflow graph functions, still it seems that Autograph is trying to transform them. How can I prevent it?

How can I force tensorflow to use my pice of code (that defines graph) as it is?

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

For some reason tensorflow wants to transform this function and reports a warning its impossible and that it will be used as it is. The question is, why there is even an attempt to use Autograph in the first place?

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.
Xyz
  • 1,522
  • 17
  • 23

1 Answers1

4

For v2.2 (and back to v1.15), you can use tf.autograph.experimental.do_not_convert:

@tf.autograph.experimental.do_not_convert
def process_fn(item):
    ...
Travis Addair
  • 427
  • 4
  • 11
  • have a similar problem but do not know how to implement answer above. Could you provide details?Where do I put the code? – Gerry P Aug 05 '20 at 22:00