• Stars
    star
    1,357
  • Rank 34,618 (Top 0.7 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interactive, node-by-node debugging and visualization for TensorFlow

TDB

*Note: This project is no longer actively being maintained. Please check out the official tfdbg debugger

TensorDebugger (TDB) is a visual debugger for deep learning. It extends TensorFlow (Google's Deep Learning framework) with breakpoints + real-time visualization of the data flowing through the computational graph.

Video Demo

Specifically, TDB is the combination of a Python library and a Jupyter notebook extension, built around Google's TensorFlow framework. Together, these extend TensorFlow with the following features:

  • Breakpoints: Set breakpoints on Ops and Tensors in the graph. Graph execution is paused on breakpoints and resumed by the user (via tdb.c()) Debugging features can be used with or without the visualization frontend.
  • Arbitrary Summary Plots: Real-time visualization of high-level information (e.g. histograms, gradient magnitudes, weight saturation) while the network is being trained. Supports arbitrary, user-defined plot functions.
  • Flexible: Mix user-defined Python and plotting functions with TensorFlow Nodes. These take in tf.Tensors and output placeholder nodes to be plugged into TensorFlow nodes. The below diagram illustrates how TDB nodes can be mixed with the TensorFlow graph.

heterogenous

Motivations

Modern machine learning models are parametrically complex and require considerable intuition to fine-tune properly.

In particular, Deep Learning methods are especially powerful, but hard to interpret in regards to their capabilities and learned representations.

Can we enable better understanding of how neural nets learn, without having to change model code or sacrifice performance? Can I finish my thesis on time?

TDB addresses these challenges by providing run-time visualization tools for neural nets. Real-time visual debugging allows training bugs to be detected sooner, thereby reducing the iteration time needed to build the right model.

Setup

To install the Python library,

pip install tfdebugger

To install the Jupyter Notebook extension, run the following in a Python terminal (you will need to have IPython or Jupyter installed)

import notebook.nbextensions
import urllib
import zipfile
SOURCE_URL = 'https://github.com/ericjang/tdb/releases/download/tdb_ext_v0.1/tdb_ext.zip'
urllib.urlretrieve(SOURCE_URL, 'tdb_ext.zip')
with zipfile.ZipFile('tdb_ext.zip', "r") as z:
    z.extractall("")
notebook.nbextensions.install_nbextension('tdb_ext',user=True)

Tutorial

To get started, check out the MNIST Visualization Demo. More examples and visualizations to come soon.

User Guide

Debugging

Start

status,result=tdb.debug(evals,feed_dict=None,breakpoints=None,break_immediately=False,session=None)

debug() behaves just like Tensorflow's Session.run(). If a breakpoint is hit, status is set to 'PAUSED' and result is set to None. Otherwise, status is set to 'FINISHED' and result is set to a list of evaluated values.

Continue

status,result=tdb.c()

Continues execution of a paused session, until the next breakpoint or end. Behaves like debug.

Step

status,result=tdb.s()

Evaluate the next node, then pause immediately to await user input. Unless we have reached the end of the execution queue, status will remain 'PAUSED'. result is set to the value of the node we just evaluated.

Where

q=tdb.get_exe_queue()

Return value: list of remaining nodes to be evaluated, in order.

print

val=tdb.get_value(node)

Returns value of an evaluated node (a string name or a tf.Tensor)

Custom Nodes

TDB supports 2 types of custom Ops:

Python

Here is an example of mixing tdb.PythonOps with TensorFlow.

Define the following function:

def myadd(ctx,a,b):
	return a+b
a=tf.constant(2)
b=tf.constant(3)
c=tdb.python_op(myadd,inputs=[a,b],outputs=[tf.placeholder(tf.int32)]) # a+b
d=tf.neg(c)
status,result=tdb.debug([d], feed_dict=None, breakpoints=None, break_immediately=False)	

When myadd gets evaluated, ctx is the instance of the PythonOp that it belongs to. You can use ctx to store state information (i.e. accumulate loss history).

Plotting

PlotOps are a special instance of PythonOp that send graphical output to the frontend.

This only works with Matplotlib at the moment, but other plotting backends (Seaborn, Bokeh, Plotly) are coming soon.

def watch_loss(ctx,loss):
  if not hasattr(ctx, 'loss_history'):
    ctx.loss_history=[]
  ctx.loss_history.append(loss)
  plt.plot(ctx.loss_history)
  plt.ylabel('loss')
ploss=tdb.plot_op(viz.watch_loss,inputs=[loss])

Refer to the MNIST Visualization Demo for more examples. You can also find more examples in the tests/ directory.

FAQ

Is TDB affiliated with TensorFlow?

No, but it is built on top of it.

What is TDB good for?

TDB is especially useful at the model prototyping stage and verifying correctness in an intuitive manner. It is also useful for high-level visualization of hidden layers during training.

How is TDB different from TensorBoard?

TensorBoard is a suite of visualization tools included with Tensorflow. Both TDB and TensorBoard attach auxiliary nodes to the TensorFlow graph in order to inspect data.

TensorBoard cannot be used concurrently with running a TensorFlow graph; log files must be written first. TDB interfaces directly with the execution of a TensorFlow graph, and allows for stepping through execution one node at a time.

Out of the box, TensorBoard currently only supports logging for a few predefined data formats.

TDB is to TensorBoard as GDB is to printf. Both are useful in different contexts.

License

Apache 2.0

More Repositories

1

awesome-graphics

Curated list of computer graphics tutorials and resources
1,048
star
2

cryptocurrency_arbitrage

Automated Trading program that detects pairwise and triangular arbitrage opportunities on altcoin/bitcoin exchanges
Python
819
star
3

draw

TensorFlow Implementation of "DRAW: A Recurrent Neural Network For Image Generation"
Python
525
star
4

gumbel-softmax

categorical variational autoencoder using the Gumbel-Softmax estimator
Jupyter Notebook
425
star
5

normalizing-flows-tutorial

Tutorial on normalizing flows.
Jupyter Notebook
293
star
6

genadv_tutorial

TensorFlow tutorial on Generative Adversarial Models
Jupyter Notebook
255
star
7

maml-jax

Implementation of Model-Agnostic Meta-Learning (MAML) in Jax
Jupyter Notebook
188
star
8

svd3

Fast singular value decomposition, diagonalization, QR decomposition of 3x3 matrices.
Mathematica
148
star
9

nf-jax

Normalizing Flows in Jax
Jupyter Notebook
105
star
10

pt-jax

Path Tracing in JAX
Jupyter Notebook
69
star
11

e2c

TensorFlow impementation of: Embed to Control: A Locally Linear Latent Dynamics Model for Control from Raw Images
Python
65
star
12

RNN-dynamics

Code and report for APMA136 Final Project
MATLAB
19
star
13

pptx-export-notes

Exports plaintext speaker notes from Microsoft Powerpoint .pptx files
Python
19
star
14

variance_reduction

Implementation of Variance Reduction Techniques in Julia
Jupyter Notebook
11
star
15

graphjs

Mathematical Graph representation in JavaScript
CoffeeScript
6
star
16

pyN

Neuron(s)-based library in Python using numpy and Blender Game Engine.
Python
6
star
17

glsl-playground

Shadertoy-compatible fragment shader viewer.
C++
5
star
18

julia-NeuralNets

Spiking neural network simulator written in Julia.
Julia
5
star
19

NeuralNets

(Yet another) C++ Simulator for Neural Networks
C++
4
star
20

geneva

activation function inspired by the Geneva drive
Jupyter Notebook
4
star
21

Social-Docking

Metropolis Monte Carlo + General AMBER Force Field implemented in JavaScript
JavaScript
3
star
22

boxbot

C++ Framework for embodied cognition / robot simulation / reinforcement learning
C++
3
star
23

node-user-agents

Quick HTTP user agent headers for slightly-immoral-and-very-improper web scraping
JavaScript
3
star
24

chaos

Jupyter Notebook
3
star
25

Hanabi.jl

customizable game engine for Hanabi, written in Julia
Julia
3
star
26

adaptive-e2c

Capstone project (Brown University)
Python
2
star
27

discord_chatbot

text-based multiplayer discord game
Python
1
star
28

cpu-render

Dumb CPU renderer for debugging shadertoy shaders
C++
1
star
29

aibook

ALife book.
HTML
1
star
30

java-graph

A simple graph class + dijkstra's
Java
1
star
31

graphjs_viz

Adds support for drawing in the graphjs library
1
star
32

ericjang.github.io

HTML
1
star
33

google-scrubber

Command-Line Utility for Scraping Google Data
1
star
34

DockJS

Molecular Docking framework built on top of ChemJS
JavaScript
1
star