Video Tutorial: Introduction to TensorFlow Debugger

Posted by


TensorFlow Debugger (tfdbg) is a powerful tool for inspecting and debugging TensorFlow models during training. In this tutorial, we will learn how to use tfdbg to inspect the internal state of your TensorFlow model using a feature called TensorFlow Debugger Screencast.

Before we start, make sure you have TensorFlow installed on your system. If not, you can install it using pip:

pip install tensorflow

Now let’s start with the tutorial:

  1. Import the necessary libraries:
import tensorflow as tf
from tensorflow.python import debug as tf_debug
  1. Load your TensorFlow model:
# Load your TensorFlow model here
model = ... 
  1. Start a TensorFlow session with tfdbg:
sess = tf_debug.LocalCLIDebugWrapperSession(tf.Session(), dump_root='/tmp/tfdbg_dump')
(sess, tf_local_commands, tf_local_captures) = sess.tf.chief()
sess.add_tensor_filter("has_inf_or_nan", tf_debug.has_inf_or_nan)
sess.run(tf.global_variables_initializer())
  1. Start the TensorFlow Debugger Screencast:
# Use the tfdbg TensorWatch tool to start the screencast
from tensorflow.python import debugger as tf_debug
from tensorflow.python.debug.lib import debug_data
from tensorflow.python.debug.lib import pydb
from tensorflow.python.debug.lib import pydb_babysit

pydb_c = pydb_babysit.LocalCLIDebugWrapperSession(tf.Session(), 
                                                  dump_root='/tmp/tfdbg_dump')
tfdbg_s = tf_debug.TensorFlowDebuggerCLIScreencastWrapper(pydb_c)
sess.run(tf.global_variables_initializer())
tfdbg_s.add_tensor_filter("has_inf_or_nan", tf_debug.has_inf_or_nan)
  1. Start training your model:
# Start training your model
for i in range(num_steps):
    sess.run(train_op)
  1. Monitor the internal state of your model:

Once you have started training your model, you can use the TensorFlow Debugger Screencast to inspect the internal state of your model in real-time. The screencast will display information such as tensor values, shapes, and gradients, allowing you to identify and fix any issues with your model.

By following these steps, you can effectively use TensorFlow Debugger Screencast to inspect and debug your TensorFlow models during training. Remember to always monitor the internal state of your model to ensure that it is performing as expected. Happy debugging!

0 0 votes
Article Rating

Leave a Reply

8 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@sangeethbalakrishnan9177
7 days ago

Need to install pyreadline before looking this video

@Juhlo123
7 days ago

Why would anyone use tensorflow?

@JohnDavis_NetSkink_Computing
7 days ago

looks interesting, but anyone know how to interpet the invoke_stepper results? Is the resulting output from invoking that command like a callstack?

@koushyarz
7 days ago

Thanks for the video.
It looks simple but it becomes hard when dealing with more complicated codes.
Can you help with this thread in github (Run Cifar10_train in debug mode (Higher Level APIs) ) :
https://github.com/tensorflow/models/issues/2345 ?

Thanks

@soarxiang7097
7 days ago

Nice!

@majd1495
7 days ago

I have a question not to be mean but you know you're supposed to be a company and your coding things with a Mac shouldn't you be using a PC

@web
7 days ago

That is sweet

@SoniaRetzer
7 days ago

good

8
0
Would love your thoughts, please comment.x
()
x