Treescope: An interactive HTML pretty-printer for ML research in IPython notebooks.
Project description
Treescope
Treescope is an interactive HTML pretty-printer and N-dimensional array ("tensor") visualizer, designed for machine learning and neural networks research in IPython notebooks. It's a drop-in replacement for the standard IPython/Colab renderer, and adds support for:
- Expanding and collapsing subtrees of rendered objects, to let you focus on the parts of your model that you care about,
- Automatically embedding faceted visualizations of arbitrary-dimensional arrays and tensors directly into the output renderings, so you can quickly understand their shapes and the distribution of their values,
- Color-coding parts of neural network models to emphasize shared structures,
- Inserting "copy path" buttons that let you easily copy the path to any part of a rendered object,
- Customizing the visualization strategy to support rendering your own data structures,
- And more!
Treescope was originally developed as the pretty-printer for the Penzai neural network library, but it also supports rendering neural networks developed with other libraries, including Equinox, Flax NNX, and PyTorch. You can also use it with basic JAX and Numpy code.
With Treescope, instead of looking at this:
You could be looking at this:
This is an interactive visualization; try clicking the ▶
buttons to expand
parts of the output! (You can also hold shift while scrolling to
scroll horizontally instead of vertically.)
Documentation on Treescope can be found at https://treescope.readthedocs.io.
Getting Started
You can install Treescope using:
pip install treescope
and import it using:
import treescope
To render a specific object in an IPython notebook with Treescope, you can use
treescope.show
, which is like print
but produces a rich interactive output.
Alternatively, you can simply configure Treescope as the default pretty printer for your notebook via:
treescope.register_as_default()
To turn on automatic array visualization, you can run:
treescope.active_autovisualizer.set_globally(treescope.ArrayAutovisualizer())
Or, if you'd like to both set up Treescope as the default pretty printer and enable automatic array visualization, you can simply run:
treescope.basic_interactive_setup(autovisualize_arrays=True)
Once you've rendered an object, try clicking on it and pressing the r
key!
This turns on "roundtrip mode", and adds qualified names to every type in the
visualization, making it easier to identify what the types in your object are.
For more information on how to use Treescope, check out the Treescope documentation.
Looking for a neural network library with first-class support for Treescope's visualization features? Try Penzai!
This is not an officially supported Google product.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for treescope-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdd79b7837bd0ab7c1051e27040a0456102bd7a3fa379b2e87957ad074473d4f |
|
MD5 | d364f255f57ed1654ddb6c58c0905641 |
|
BLAKE2b-256 | 444240621de787bc78259e46a407ea3c3dbf8d778a9ffb6159ff06fdc792115c |