tff.aggregators.clipping_factory
Stay organized with collections
Save and categorize content based on your preferences.
Creates an aggregation factory to perform L2 clipping.
tff.aggregators.clipping_factory(
clipping_norm: Union[float, tff.templates.EstimationProcess
],
inner_agg_factory: tff.aggregators.AggregationFactory
,
clipped_count_sum_factory: Optional[tff.aggregators.UnweightedAggregationFactory
] = None
) -> tff.aggregators.AggregationFactory
Used in the notebooks
The created tff.templates.AggregationProcess
projects the values onto an
L2 ball (also referred to as "clipping") with norm determined by the provided
clipping_norm
, before aggregating the values as specified by
inner_agg_factory
.
The provided clipping_norm
can either be a constant (for fixed norm), or an
instance of tff.templates.EstimationProcess
(for adaptive norm). If it is an
estimation process, the value returned by its report
method will be used as
the clipping 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 clipping norm based on the set of aggregated
values. For example if a tff.aggregators.PrivateQuantileEstimationProcess
is
used, the clip 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
clipped_count
: The number of aggregands clipped.
clipping_norm
: The norm used to determine whether to clip an aggregand.
The returned AggregationFactory
takes its weightedness
(UnweightedAggregationFactory
vs. WeightedAggregationFactory
) from
inner_agg_factory
.
Args |
clipping_norm
|
Either a float (for fixed norm) or an EstimationProcess
(for adaptive norm) that specifies the norm over which the values should
be clipped.
|
inner_agg_factory
|
A factory specifying the type of aggregation to be done
after clipping.
|
clipped_count_sum_factory
|
A factory specifying the type of aggregation done
for clipped_count measurement. If None , tff.aggregators.SumFactory
will be used.
|
Returns |
An aggregation factory to perform L2 clipping.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-20 UTC.
[null,null,["Last updated 2024-09-20 UTC."],[],[],null,["# tff.aggregators.clipping_factory\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [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) |\n\nCreates an aggregation factory to perform L2 clipping. \n\n tff.aggregators.clipping_factory(\n clipping_norm: Union[float, ../../tff/templates/EstimationProcess],\n inner_agg_factory: ../../tff/aggregators/AggregationFactory,\n clipped_count_sum_factory: Optional[../../tff/aggregators/UnweightedAggregationFactory] = None\n ) -\u003e ../../tff/aggregators/AggregationFactory\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|---------------------------------------------------------------------------------------------------------------------------------|\n| - [Tuning recommended aggregations for learning](https://www.tensorflow.org/federated/tutorials/tuning_recommended_aggregators) |\n\nThe created [`tff.templates.AggregationProcess`](../../tff/templates/AggregationProcess) projects the values onto an\nL2 ball (also referred to as \"clipping\") with norm determined by the provided\n`clipping_norm`, before aggregating the values as specified by\n`inner_agg_factory`.\n\nThe provided `clipping_norm` can either be a constant (for fixed norm), or an\ninstance of [`tff.templates.EstimationProcess`](../../tff/templates/EstimationProcess) (for adaptive norm). If it is an\nestimation process, the value returned by its `report` method will be used as\nthe clipping norm. Its `next` method needs to accept a scalar float32 at\nclients, corresponding to the norm of value being aggregated. The process can\nthus adaptively determine the clipping norm based on the set of aggregated\nvalues. For example if a [`tff.aggregators.PrivateQuantileEstimationProcess`](../../tff/aggregators/PrivateQuantileEstimationProcess) is\nused, the clip will be an estimate of a quantile of the norms of the values\nbeing aggregated.\n\nThe `value_type` provided to the `create` method must be a structure of\nfloats, but they do not all need to be the same, e.g. a mix of `np.float32`\nand `np.float16` dtypes is allowed.\n\nThe created process will report measurements\n\n- `clipped_count`: The number of aggregands clipped.\n- `clipping_norm`: The norm used to determine whether to clip an aggregand.\n\nThe returned `AggregationFactory` takes its weightedness\n(`UnweightedAggregationFactory` vs. `WeightedAggregationFactory`) from\n`inner_agg_factory`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `clipping_norm` | Either a float (for fixed norm) or an `EstimationProcess` (for adaptive norm) that specifies the norm over which the values should be clipped. |\n| `inner_agg_factory` | A factory specifying the type of aggregation to be done after clipping. |\n| `clipped_count_sum_factory` | A factory specifying the type of aggregation done for `clipped_count` measurement. If `None`, [`tff.aggregators.SumFactory`](../../tff/aggregators/SumFactory) will be used. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| An aggregation factory to perform L2 clipping. ||\n\n\u003cbr /\u003e"]]