Watch talks from the 2019 TensorFlow Dev Summit Watch now

tf.autograph.to_code

Aliases:

  • tf.autograph.to_code
  • tf.contrib.autograph.to_code
tf.autograph.to_code(
    entity,
    recursive=True,
    arg_values=None,
    arg_types=None,
    indentation='  ',
    experimental_optional_features=tf.autograph.experimental.Feature.ALL,
    experimental_partial_types=None
)

Defined in tensorflow/python/autograph/impl/api.py.

Similar to to_graph, but returns Python source code as a string.

Also see: tf.autograph.to_graph.

to_graph returns the Python source code that can be used to generate a TensorFlow graph that is functionally identical to the input Python code.

Args:

  • entity: Python callable or class to convert.
  • recursive: Whether to recursively convert any functions that the converted function may call.
  • arg_values: Optional dict of value hints for symbols including function arguments mapping string names to actual values. For example, arg_values={'a': 1} will map the variable a to the value 1.
  • arg_types: Optional dict of type hints for symbols including function arguments. Type hints allow specifying just the type of a variable, rather than a specific value.
  • indentation: The string to use for indenting. Typically two or four spaces, or just the tab character.
  • experimental_optional_features: None, a tuple of, or a single tf.autograph.experimental.Feature value. Controls the use of optional features in the conversion process.
  • experimental_partial_types: A set of type values, reserved for internal use.

Returns:

The converted code as string.