# Module: tf_privacy.tree_aggregation

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/privacy/blob/v0.9.0/privacy/privacy/dp_query/tree_aggregation.py) |

Tree aggregation algorithm.

`TreeAggregator` and `EfficientTreeAggregator` compute cumulative sums of noise
based on tree aggregation. When using an appropriate noise function (e.g.,
Gaussian noise), it allows for efficient differentially private algorithms under
continual observation, without prior subsampling or shuffling assumptions. This
module implements the core logic of tree aggregation in Tensorflow, which serves
as helper functions for `tree_aggregation_query`. This module and helper
functions are publicly accessible.

## Classes

[`class EfficientTreeAggregator`](https://www.tensorflow.org/responsible_ai/privacy/api_docs/python/tf_privacy/tree_aggregation/EfficientTreeAggregator): Efficient tree aggregator to compute accumulated noise.

[`class GaussianNoiseGenerator`](https://www.tensorflow.org/responsible_ai/privacy/api_docs/python/tf_privacy/tree_aggregation/GaussianNoiseGenerator): Gaussian noise generator with counter as pseudo state.

[`class StatelessValueGenerator`](https://www.tensorflow.org/responsible_ai/privacy/api_docs/python/tf_privacy/tree_aggregation/StatelessValueGenerator): A wrapper for stateless value generator that calls a no-arg function.

[`class TreeAggregator`](https://www.tensorflow.org/responsible_ai/privacy/api_docs/python/tf_privacy/tree_aggregation/TreeAggregator): Tree aggregator to compute accumulated noise in private algorithms.

[`class TreeState`](https://www.tensorflow.org/responsible_ai/privacy/api_docs/python/tf_privacy/tree_aggregation/TreeState): Class defining state of the tree.

[`class ValueGenerator`](https://www.tensorflow.org/responsible_ai/privacy/api_docs/python/tf_privacy/tree_aggregation/ValueGenerator): Base class establishing interface for stateful value generation.

## Functions

[`get_step_idx(...)`](https://www.tensorflow.org/responsible_ai/privacy/api_docs/python/tf_privacy/tree_aggregation/get_step_idx): Returns the current leaf node index based on [`TreeState.level_buffer_idx`](https://www.tensorflow.org/responsible_ai/privacy/api_docs/python/tf_privacy/tree_aggregation/TreeState#level_buffer_idx).