{"id":15116114,"url":"https://github.com/google-deepmind/treescope","last_synced_at":"2025-06-17T00:39:18.425Z","repository":{"id":250213298,"uuid":"833341995","full_name":"google-deepmind/treescope","owner":"google-deepmind","description":"An interactive HTML pretty-printer for machine learning research in IPython notebooks.","archived":false,"fork":false,"pushed_at":"2025-05-01T17:49:26.000Z","size":882,"stargazers_count":419,"open_issues_count":7,"forks_count":24,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-09T06:55:30.761Z","etag":null,"topics":["machine-learning","ndarray","neural-networks","pretty-printing","visualization"],"latest_commit_sha":null,"homepage":"https://treescope.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google-deepmind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-24T21:06:00.000Z","updated_at":"2025-05-28T20:10:48.000Z","dependencies_parsed_at":"2024-07-25T22:58:24.277Z","dependency_job_id":"f3b1b1c3-3b99-4440-95d9-19b501394aa9","html_url":"https://github.com/google-deepmind/treescope","commit_stats":null,"previous_names":["google-deepmind/treescope"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/google-deepmind/treescope","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-deepmind%2Ftreescope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-deepmind%2Ftreescope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-deepmind%2Ftreescope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-deepmind%2Ftreescope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google-deepmind","download_url":"https://codeload.github.com/google-deepmind/treescope/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-deepmind%2Ftreescope/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260268635,"owners_count":22983601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["machine-learning","ndarray","neural-networks","pretty-printing","visualization"],"created_at":"2024-09-26T01:44:10.002Z","updated_at":"2025-06-17T00:39:18.414Z","avatar_url":"https://github.com/google-deepmind.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# 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![Screenshot of a parameter dictionary without Treescope](docs/_static/readme_teaser_before.png)\n\nYou could be looking at this:\n\n![Screenshot of a parameter dictionary using Treescope](docs/_static/readme_teaser_after.png)\n\nThis is an interactive visualization; try clicking the `▶` 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\u003e [!TIP]\n\u003e If Treescope's outputs are too verbose, or if you are using a terminal that\n\u003e wraps lines, you can configure Treescope to abbreviate collapsed objects at a\n\u003e given depth using:\n\u003e\n\u003e ```python\n\u003e treescope.basic_interactive_setup(\n\u003e     autovisualize_arrays=True,\n\u003e     abbreviation_threshold=1,  # or a different value\n\u003e )\n\u003e ```\n\u003e\n\u003e You can also configure the abbreviation threshold manually by overriding\n\u003e `treescope.abbreviation_threshold` using the `.set_globally` or `.set_scoped`\n\u003e 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle-deepmind%2Ftreescope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle-deepmind%2Ftreescope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle-deepmind%2Ftreescope/lists"}