LostTech.TensorFlow : API Documentation

Type tf.autograph

Namespace tensorflow

Public static methods

void set_verbosity(object level, bool alsologtostdout)

Sets the AutoGraph verbosity level.

_Debug logging in AutoGraph_

More verbose logging is useful to enable when filing bug reports or doing more in-depth debugging.

There are two means to control the logging verbosity:

* The `set_verbosity` function

* The `AUTOGRAPH_VERBOSITY` environment variable

`set_verbosity` takes precedence over the environment variable. Logs entries are output to [absl](https://abseil.io)'s [default output](https://abseil.io/docs/python/guides/logging), with `INFO` level. Logs can be mirrored to stdout by using the `alsologtostdout` argument. Mirroring is enabled by default when Python runs in interactive mode.
Parameters
object level
int, the verbosity level; larger values specify increased verbosity; 0 means no logging. When reporting bugs, it is recommended to set this value to a larger number, like 10.
bool alsologtostdout
bool, whether to also output log messages to `sys.stdout`.
Show Example
import os
            import tensorflow as tf 

os.environ['AUTOGRAPH_VERBOSITY'] = 5 # Verbosity is now 5

tf.autograph.set_verbosity(0) # Verbosity is now 0

os.environ['AUTOGRAPH_VERBOSITY'] = 1 # No effect, because set_verbosity was already called.

object set_verbosity_dyn(object level, ImplicitContainer<T> alsologtostdout)

string to_code(object entity, bool recursive, object arg_values, object arg_types, string indentation, object experimental_optional_features)

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.
Parameters
object entity
Python callable or class to convert.
bool recursive
Whether to recursively convert any functions that the converted function may call.
object arg_values
Deprecated.
object arg_types
Deprecated.
string indentation
Deprecated.
object 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.
Returns
string
The converted code as string.

object to_code_dyn(object entity, ImplicitContainer<T> recursive, object arg_values, object arg_types, ImplicitContainer<T> indentation, object experimental_optional_features)

object to_graph(object entity, bool recursive, object arg_values, object arg_types, object experimental_optional_features)

Converts a Python entity into a TensorFlow graph.

Also see: tf.autograph.to_code, tf.function.

Unlike tf.function, `to_graph` is a low-level transpiler that converts Python code to TensorFlow graph code. It does not implement any caching, variable management or create any actual ops, and is best used where greater control over the generated TensorFlow graph is desired. Another difference from tf.function is that `to_graph` will not wrap the graph into a TensorFlow function or a Python callable. Internally, tf.function uses `to_graph`.

_Example Usage_ Supported Python entities include: * functions * classes * object methods

Functions are converted into new functions with converted code.

Classes are converted by generating a new class whose methods use converted code.

Methods are converted into unbound function that have an additional first argument called `self`.
Parameters
object entity
Python callable or class to convert.
bool recursive
Whether to recursively convert any functions that the converted function may call.
object arg_values
Deprecated.
object arg_types
Deprecated.
object 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.
Returns
object
Same as `entity`, the converted Python function or class.
Show Example
def foo(x):
              if x > 0:
                y = x * x
              else:
                y = -x
              return y 

converted_foo = to_graph(foo)

x = tf.constant(1) y = converted_foo(x) # converted_foo is a TensorFlow Op-like. assert is_tensor(y)

object to_graph_dyn(object entity, ImplicitContainer<T> recursive, object arg_values, object arg_types, object experimental_optional_features)

void trace(Object[] args)

Traces argument information at compilation time.

`trace` is useful when debugging, and it always executes during the tracing phase, that is, when the TF graph is constructed.

_Example usage_
Parameters
Object[] args
Arguments to print to `sys.stdout`.
Show Example
import tensorflow as tf 

for i in tf.range(10): tf.autograph.trace(i) # Output:

object trace_dyn(Object[] args)

Traces argument information at compilation time.

`trace` is useful when debugging, and it always executes during the tracing phase, that is, when the TF graph is constructed.

_Example usage_
Parameters
Object[] args
Arguments to print to `sys.stdout`.
Show Example
import tensorflow as tf 

for i in tf.range(10): tf.autograph.trace(i) # Output:

Public properties

PythonFunctionContainer set_verbosity_fn get;

PythonFunctionContainer to_code_fn_ get;

PythonFunctionContainer to_graph_fn_ get;

PythonFunctionContainer trace_fn get;