Relevant source material
TensorFlow Debugger Screencast - YouTube
DebugTFBasics

I plan on building a mode for emacs that includes syntax highlighting and keyboard macros, but I’ll have to wait until tfdb is released for TF2.0.

Wrapping TensorFlow Sessions With tfdbg

Add the following lines of code to use tfdbg and then contain the Session object using a debugger wrapper.

1
from tensorflow.python import debug as tf_debug
  • CLI should be called before and after Session.run() if you wish to take control of the execution and know the internal state of the graph.
  • Filters can be added for assisting the diagnosis.
    In the provided example, there is already a filter called tfdbg.has_inf_or_nan, which determine the presence of nan or inf in any in-between tensors, which are neither inputs nor outputs.
  • You may write your own custom filters.

Debugging TensorFlow Model Training with tfdbg

This only works for TensorFlow 1 at the moment.

Typical use-cases

  • finding NaNs
  • finding Infs (infinities)

1
ewwlinks +/"4. Debugging TensorFlow Model Training with tfdbg" "https://data-flair.training/blogs/tensorflow-debugging/"

Both the conda-run and python3.7 scripts put me in the anaconda environment.

1
2
3
4
5
6
7
8
#!/bin/bash
export TTY

( hs "$(basename "$0")" "$@" "#" "<==" "$(ps -o comm= $PPID)" 0</dev/null ) &>/dev/null

. $HOME/sh-source/conda-init

"$@"
1
2
python3.7 -m tensorflow.python.debug.examples.debug_mnist –debug
conda-run python -m tensorflow.python.debug.examples.debug_mnist –debug

The tfdbg CLI does not appear in tensorflow 2.0.

https://github.com/tensorflow/tensorflow/issues/29679

TF Debugger (tfdbg) for TF v2.0 is still being designed and will be made available at a later time.

As you pointed out, tfdbg is originally designed for TF v1.x and is centered around the tf.Session API.

As tf.Session is replaced by eager execution and tf.functions in 2.0, the debugger feature needs to be adapted to the architectural change.

If you have a specific use case (e.g., finding Infinities and NaNs, or other debugging workflows), please let us know.

It’ll inform the design of the new version of tfdbg.