user3970726
user3970726

Reputation:

Turning off tensorflow autograph

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.

Upvotes: 2

Views: 1612

Answers (1)

Travis Addair
Travis Addair

Reputation: 427

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):
    ...

Upvotes: 4

Related Questions