# tff.aggregators.zeroing_factory

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

Creates an aggregation factory to perform zeroing.

    tff.aggregators.zeroing_factory(
        zeroing_norm: Union[float, https://www.tensorflow.org/federated/api_docs/python/tff/templates/EstimationProcess],
        inner_agg_factory: _T,
        norm_order: float = math.inf,
        zeroed_count_sum_factory: Optional[https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/UnweightedAggregationFactory] = None
    ) -> _T

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Tuning recommended aggregations for learning](https://www.tensorflow.org/federated/tutorials/tuning_recommended_aggregators) |

The created [`tff.templates.AggregationProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/AggregationProcess) zeroes out any values whose
norm is greater than that determined by the provided `zeroing_norm`, before
aggregating the values as specified by `inner_agg_factory`. Note that for
weighted aggregation if some value is zeroed, the weight is unchanged. So for
example if you have a zeroed weighted mean and a lot of zeroing occurs, the
average will tend to be pulled toward zero. This is for consistency between
weighted and unweighted aggregation

The provided `zeroing_norm` can either be a constant (for fixed norm), or an
instance of [`tff.templates.EstimationProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/EstimationProcess) (for adaptive norm). If it is an
estimation process, the value returned by its `report` method will be used as
the zeroing norm. Its `next` method needs to accept a scalar float32 at
clients, corresponding to the norm of value being aggregated. The process can
thus adaptively determine the zeroing norm based on the set of aggregated
values. For example if a [`tff.aggregators.PrivateQuantileEstimationProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/PrivateQuantileEstimationProcess) is
used, the zeroing norm will be an estimate of a quantile of the norms of the
values being aggregated.

The `value_type` provided to the `create` method must be a structure of
floats, but they do not all need to be the same, e.g. a mix of `np.float32`
and `np.float16` dtypes is allowed.

The created process will report measurements

- `zeroed_count`: The number of aggregands zeroed out.
- `zeroing_norm`: The norm used to determine whether to zero out an aggregand.

The returned `AggregationFactory` takes its weightedness
(`UnweightedAggregationFactory` vs. `WeightedAggregationFactory`) from
`inner_agg_factory`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `zeroing_norm` | Either a float (for fixed norm) or an `EstimationProcess` (for adaptive norm) that specifies the norm over which the values should be zeroed. |
| `inner_agg_factory` | A factory specifying the type of aggregation to be done after zeroing. |
| `norm_order` | A float for the order of the norm. Must be 1., 2., or infinity. |
| `zeroed_count_sum_factory` | A factory specifying the type of aggregation done for `zeroed_count` measurement. If `None`, [`tff.aggregators.SumFactory`](https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/SumFactory) will be used. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| An aggregation factory to perform zeroing. ||

<br />