Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling `@tf.function` decorators for debugging?

In TensorFlow 2, the @tf.function decorator allows for Python functions to become TensorFlow graphs (more or less) and can lead to some performance improvements. However, when decorated this way, Python no longer traces the functions each time they run. This makes debugging the functions with Python debuggers a bit more difficult. Is there a way to disable all @tf.function decorators temporarily to allow for easy debugging?

like image 518
golmschenk Avatar asked May 26 '19 20:05

golmschenk


People also ask

What does TF function decorator do?

You can use tf. function to make graphs out of your programs. It is a transformation tool that creates Python-independent dataflow graphs out of your Python code. This will help you create performant and portable models, and it is required to use SavedModel .

What is TF config Run_functions_eagerly true?

config. run_functions_eagerly(True) will make all invocations of tf. function run eagerly instead of running as a traced graph function. This can be useful for debugging.

What is AutoGraph in TensorFlow?

AutoGraph transforms a subset of Python which operates on TensorFlow objects into equivalent TensorFlow graph code. When executing the graph, it has the same effect as if you ran the original code in eager mode.


1 Answers

Use tf.config.run_functions_eagerly(True).

like image 85
Alexander Korneev Avatar answered Sep 23 '22 10:09

Alexander Korneev