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
Try Google Cloud Risk-Free With $300 in Credit Icon
Try Google Cloud Risk-Free With $300 in Credit

No hidden charges. No surprise bills. Cancel anytime.

Use your credit across every product. Compute, storage, AI, analytics. When it runs out, 20+ products stay free. You only pay when you choose to.
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