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 serves as a drop-in replacement for the standard IPython/Colab renderer, enhancing output with features like expandable/collapsible subtrees, embedded faceted visualizations of arbitrary-dimensional arrays, and color-coding for model structures. It supports inspecting data from libraries such as JAX, NumPy, PyTorch, Equinox, Flax NNX, and Penzai. Maintained by Google DeepMind, the current version is 0.1.10.
pip install treescopeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to enable Treescope as the default renderer in an IPython/Colab environment and visualize a complex, nested data structure containing both JAX and NumPy arrays. After `basic_interactive_setup()`, simply outputting a variable in a notebook cell will automatically trigger Treescope's rich, interactive HTML visualization.
Call `treescope.basic_interactive_setup()` at the beginning of your notebook session to enable Treescope as the default renderer and activate array autovisualization.
Encourage users to click on rendered objects and experiment with keyboard shortcuts (like 'r') within the IPython output to unlock interactive exploration. Refer to official documentation for interactive features.
For bespoke data structures, consult the 'Customizing Treescope' section of the official documentation to learn how to define custom visualizers or `__treescope_repr__` methods.
Run `pip install treescope` in your terminal or notebook. For Colab, use `pip install 'treescope[colab]'`.
Add `import treescope` at the beginning of your script or notebook.
Import the 'treescope' module and then set its 'active' attribute: `import treescope; treescope.active = True`.
Pass the object you wish to display as an argument, for example: `treescope.display(my_variable)`.