Name | treescope JSON |
Version |
0.1.10
JSON |
| download |
home_page | None |
Summary | Treescope: An interactive HTML pretty-printer for ML research in IPython notebooks. |
upload_time | 2025-08-08 05:43:48 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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](https://penzai.readthedocs.io/en/stable), but
it also supports rendering neural networks developed with other libraries,
including
[Equinox](https://docs.kidger.site/equinox/),
[Flax NNX](https://flax.readthedocs.io/en/latest/nnx/index.html),
and
[PyTorch](https://pytorch.org/docs/stable/).
You can also use it with basic
[JAX](https://jax.readthedocs.io/en/latest/)
and
[Numpy](https://numpy.org/doc/stable/)
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](https://treescope.readthedocs.io).
## Getting Started
You can install Treescope using:
```bash
pip install treescope
```
and import it using:
```python
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:
```python
treescope.register_as_default()
```
To turn on automatic array visualization, you can run:
```python
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:
```python
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.
> [!TIP]
> If Treescope's outputs are too verbose, or if you are using a terminal that
> wraps lines, you can configure Treescope to abbreviate collapsed objects at a
> given depth using:
>
> ```python
> treescope.basic_interactive_setup(
> autovisualize_arrays=True,
> abbreviation_threshold=1, # or a different value
> )
> ```
>
> You can also configure the abbreviation threshold manually by overriding
> `treescope.abbreviation_threshold` using the `.set_globally` or `.set_scoped`
> methods.
For more information on how to use Treescope, check out the
[Treescope documentation](https://treescope.readthedocs.io).
Looking for a neural network library with first-class support for Treescope's
visualization features?
Try [Penzai](https://penzai.readthedocs.io/en/stable)!
## Citation
If you have found Treescope to be useful for your research, please consider
citing the following writeup (also available on [arXiv](https://arxiv.org/abs/2408.00211)):
```
@article{johnson2024penzai,
author={Daniel D. Johnson},
title={{Penzai} + {Treescope}: A Toolkit for Interpreting, Visualizing, and Editing Models As Data},
year={2024},
journal={ICML 2024 Workshop on Mechanistic Interpretability}
}
```
---
*This is not an officially supported Google product.*
Raw data
{
"_id": null,
"home_page": null,
"name": "treescope",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "The Treescope Authors <treescope-dev@google.com>",
"download_url": "https://files.pythonhosted.org/packages/f0/2a/d13d3c38862632742d2fe2f7ae307c431db06538fd05ca03020d207b5dcc/treescope-0.1.10.tar.gz",
"platform": null,
"description": "# Treescope\n\nTreescope is an interactive HTML pretty-printer and N-dimensional array\n(\"tensor\") visualizer, designed for machine learning and neural networks\nresearch in IPython notebooks. It's a drop-in replacement for the standard\nIPython/Colab renderer, and adds support for:\n\n* Expanding and collapsing subtrees of rendered objects, to let you focus on\n the parts of your model that you care about,\n* Automatically embedding faceted visualizations of arbitrary-dimensional arrays\n and tensors directly into the output renderings, so you can quickly understand\n their shapes and the distribution of their values,\n* Color-coding parts of neural network models to emphasize shared structures,\n* Inserting \"copy path\" buttons that let you easily copy the path to any part of\n a rendered object,\n* Customizing the visualization strategy to support rendering your own data\n structures,\n* And more!\n\nTreescope was originally developed as the pretty-printer for the\n[Penzai neural network library](https://penzai.readthedocs.io/en/stable), but\nit also supports rendering neural networks developed with other libraries,\nincluding\n[Equinox](https://docs.kidger.site/equinox/),\n[Flax NNX](https://flax.readthedocs.io/en/latest/nnx/index.html),\nand\n[PyTorch](https://pytorch.org/docs/stable/).\nYou can also use it with basic\n[JAX](https://jax.readthedocs.io/en/latest/)\nand\n[Numpy](https://numpy.org/doc/stable/)\ncode.\n\n\nWith Treescope, instead of looking at this:\n\n\n\nYou could be looking at this:\n\n\n\nThis is an interactive visualization; try clicking the `\u25b6` buttons to expand\nparts of the output! (You can also hold shift while scrolling to\nscroll horizontally instead of vertically.)\n\nDocumentation on Treescope can be found at\n[https://treescope.readthedocs.io](https://treescope.readthedocs.io).\n\n\n## Getting Started\n\nYou can install Treescope using:\n\n```bash\npip install treescope\n```\n\nand import it using:\n\n```python\nimport treescope\n```\n\nTo render a specific object in an IPython notebook with Treescope, you can use\n`treescope.show`, which is like `print` but produces a rich interactive output.\n\nAlternatively, you can simply configure Treescope as the default pretty printer\nfor your notebook via:\n\n```python\ntreescope.register_as_default()\n```\n\nTo turn on automatic array visualization, you can run:\n\n```python\ntreescope.active_autovisualizer.set_globally(treescope.ArrayAutovisualizer())\n```\n\nOr, if you'd like to both set up Treescope as the default pretty printer and\nenable automatic array visualization, you can simply run:\n\n```python\ntreescope.basic_interactive_setup(autovisualize_arrays=True)\n```\n\nOnce you've rendered an object, try clicking on it and pressing the `r` key!\nThis turns on \"roundtrip mode\", and adds qualified names to every type in the\nvisualization, making it easier to identify what the types in your object are.\n\n> [!TIP]\n> If Treescope's outputs are too verbose, or if you are using a terminal that\n> wraps lines, you can configure Treescope to abbreviate collapsed objects at a\n> given depth using:\n>\n> ```python\n> treescope.basic_interactive_setup(\n> autovisualize_arrays=True,\n> abbreviation_threshold=1, # or a different value\n> )\n> ```\n>\n> You can also configure the abbreviation threshold manually by overriding\n> `treescope.abbreviation_threshold` using the `.set_globally` or `.set_scoped`\n> methods.\n\nFor more information on how to use Treescope, check out the\n[Treescope documentation](https://treescope.readthedocs.io).\n\nLooking for a neural network library with first-class support for Treescope's\nvisualization features?\nTry [Penzai](https://penzai.readthedocs.io/en/stable)!\n\n## Citation\n\nIf you have found Treescope to be useful for your research, please consider\nciting the following writeup (also available on [arXiv](https://arxiv.org/abs/2408.00211)):\n\n```\n@article{johnson2024penzai,\n author={Daniel D. Johnson},\n title={{Penzai} + {Treescope}: A Toolkit for Interpreting, Visualizing, and Editing Models As Data},\n year={2024},\n journal={ICML 2024 Workshop on Mechanistic Interpretability}\n}\n```\n\n---\n\n*This is not an officially supported Google product.*\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Treescope: An interactive HTML pretty-printer for ML research in IPython notebooks.",
"version": "0.1.10",
"project_urls": {
"homepage": "https://github.com/google-deepmind/treescope",
"repository": "https://github.com/google-deepmind/treescope"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "432b36e984399089c026a6499ac8f7401d38487cf0183839a4aa78140d373771",
"md5": "01a8a8363a51c555a56899c1f090da4f",
"sha256": "dde52f5314f4c29d22157a6fe4d3bd103f9cae02791c9e672eefa32c9aa1da51"
},
"downloads": -1,
"filename": "treescope-0.1.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "01a8a8363a51c555a56899c1f090da4f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 182255,
"upload_time": "2025-08-08T05:43:46",
"upload_time_iso_8601": "2025-08-08T05:43:46.673331Z",
"url": "https://files.pythonhosted.org/packages/43/2b/36e984399089c026a6499ac8f7401d38487cf0183839a4aa78140d373771/treescope-0.1.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f02ad13d3c38862632742d2fe2f7ae307c431db06538fd05ca03020d207b5dcc",
"md5": "cbd0938647fae90d193c8f41fb75bbee",
"sha256": "20f74656f34ab2d8716715013e8163a0da79bdc2554c16d5023172c50d27ea95"
},
"downloads": -1,
"filename": "treescope-0.1.10.tar.gz",
"has_sig": false,
"md5_digest": "cbd0938647fae90d193c8f41fb75bbee",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 138870,
"upload_time": "2025-08-08T05:43:48",
"upload_time_iso_8601": "2025-08-08T05:43:48.048242Z",
"url": "https://files.pythonhosted.org/packages/f0/2a/d13d3c38862632742d2fe2f7ae307c431db06538fd05ca03020d207b5dcc/treescope-0.1.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-08 05:43:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "google-deepmind",
"github_project": "treescope",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "treescope"
}