Tree (dm-tree) is a lightweight Python library developed by Google DeepMind for manipulating nested data structures (also called pytrees). It generalizes Python’s built-in map function to operate over arbitrarily nested collections — including lists, tuples, dicts, and custom container types — while preserving their structure. This makes it particularly useful in machine learning pipelines and JAX-based workflows, where complex parameter trees or hierarchical state representations are common. The library provides efficient operations such as flatten, unflatten, and map_structure, enabling users to apply functions to all leaves of a nested structure seamlessly. Backed by a high-performance C++ core, tree is optimized for large-scale, performance-critical applications.

Features

  • Simple installation via PyPI or GitHub
  • Compatible with frameworks like TensorFlow, JAX, and Sonnet
  • Backed by a C++ implementation for high-speed operations
  • Apply functions recursively to all leaves in nested data structures
  • Preserve the structure of lists, tuples, dicts, and other containers
  • Flatten and unflatten complex structures efficiently

Project Samples

Project Activity

See All Activity >

Categories

Libraries

License

Apache License V2.0

Follow Tree

Tree Web Site

Other Useful Business Software
Gemini 3 and 200+ AI Models on One Platform Icon
Gemini 3 and 200+ AI Models on One Platform

Access Google's best plus Claude, Llama, and Gemma. Fine-tune and deploy from one console.

Build generative AI apps with Vertex AI. Switch between models without switching platforms.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Tree!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Programming Language

C++, Python

Related Categories

Python Libraries, C++ Libraries

Registered

2025-10-09