tff.learning.metrics.SecureSumFactory
Stay organized with collections
Save and categorize content based on your preferences.
Aggregation Factory that performs secure summation over metrics.
Inherits From: UnweightedAggregationFactory
tff.learning.metrics.SecureSumFactory(
metric_value_ranges: Optional[UserMetricValueRangeDict] = None
)
The created tff.templates.AggregationProcess
uses the inner summation
processes created by the tff.aggregators.SecureSumFactory
to sum unfinalized
metrics from tff.CLIENTS
to tff.SERVER
.
Internally metrics are grouped by their value range and dtype, and only one
secure aggregation process will be created for each group. This is an
optimization for computation tracing and compiling, which can be slow
when there are a large number of independent aggregations.
The initialize
function initializes the state
for each inner secure
aggregation progress. The next
function takes the state
and local
unfinalized metrics reported from tff.CLIENTS
, and returns a
tff.templates.MeasuredProcessOutput
object with the following properties:
state
: an collections.OrderedDict
of the state
s of the inner secure
aggregation processes.
result
: an collections.OrderedDict
of secure summed unfinalized
metrics.
measurements
: an collections.OrderedDict
of the measurements of inner
secure aggregation processes.
Args |
metric_value_ranges
|
An optional collections.OrderedDict that matches
the structure of local_unfinalized_metrics_type (a value for each
tff.types.TensorType in the type tree). Each leaf in the tree should
have a 2-tuple that defines the range of expected values for that
variable in the metric. If the entire structure is None , a default
range of [0.0, 2.0**20 - 1] will be applied to integer variables and
auto-tuned bounds will be applied to float variable. Each leaf may also
be None , which will also get the default range according to the
variable value type; allowing partial user sepcialization. At runtime,
values that fall outside the ranges specified at the leaves will be
clipped to within the range.
|
Raises |
TypeError
|
If metric_value_ranges type mismatches.
|
Methods
create
View source
create(
local_unfinalized_metrics_type: tff.types.StructWithPythonType
) -> tff.templates.AggregationProcess
Creates an AggregationProcess
for secure summation over metrics.
Raises |
TypeError
|
If any argument type mismatches.
|
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.learning.metrics.SecureSumFactory\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\nAggregation Factory that performs secure summation over metrics.\n\nInherits From: [`UnweightedAggregationFactory`](../../../tff/aggregators/UnweightedAggregationFactory) \n\n tff.learning.metrics.SecureSumFactory(\n metric_value_ranges: Optional[UserMetricValueRangeDict] = None\n )\n\nThe created [`tff.templates.AggregationProcess`](../../../tff/templates/AggregationProcess) uses the inner summation\nprocesses created by the [`tff.aggregators.SecureSumFactory`](../../../tff/aggregators/SecureSumFactory) to sum unfinalized\nmetrics from [`tff.CLIENTS`](../../../tff#CLIENTS) to [`tff.SERVER`](../../../tff#SERVER).\n\nInternally metrics are grouped by their value range and dtype, and only one\nsecure aggregation process will be created for each group. This is an\noptimization for computation tracing and compiling, which can be slow\nwhen there are a large number of independent aggregations.\n\nThe `initialize` function initializes the `state` for each inner secure\naggregation progress. The `next` function takes the `state` and local\nunfinalized metrics reported from [`tff.CLIENTS`](../../../tff#CLIENTS), and returns a\n[`tff.templates.MeasuredProcessOutput`](../../../tff/templates/MeasuredProcessOutput) object with the following properties:\n\n- `state`: an `collections.OrderedDict` of the `state`s of the inner secure aggregation processes.\n- `result`: an `collections.OrderedDict` of secure summed unfinalized metrics.\n- `measurements`: an `collections.OrderedDict` of the measurements of inner secure aggregation processes.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `metric_value_ranges` | An optional `collections.OrderedDict` that matches the structure of `local_unfinalized_metrics_type` (a value for each [`tff.types.TensorType`](../../../tff/types/TensorType) in the type tree). Each leaf in the tree should have a 2-tuple that defines the range of expected values for that variable in the metric. If the entire structure is `None`, a default range of `[0.0, 2.0**20 - 1]` will be applied to integer variables and auto-tuned bounds will be applied to float variable. Each leaf may also be `None`, which will also get the default range according to the variable value type; allowing partial user sepcialization. At runtime, values that fall outside the ranges specified at the leaves will be clipped to within the range. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|-------------------------------------------|\n| `TypeError` | If `metric_value_ranges` type mismatches. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `create`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n create(\n local_unfinalized_metrics_type: ../../../tff/types/StructWithPythonType\n ) -\u003e ../../../tff/templates/AggregationProcess\n\nCreates an `AggregationProcess` for secure summation over metrics.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `local_unfinalized_metrics_type` | A [`tff.types.StructWithPythonType`](../../../tff/types/StructWithPythonType) (with `collections.OrderedDict` as the Python container) of a client's local unfinalized metrics. For example, `local_unfinalized_metrics` could represent the output type of [`tff.learning.models.VariableModel.report_local_unfinalized_metrics()`](../../../tff/learning/models/VariableModel#report_local_unfinalized_metrics). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| An instance of [`tff.templates.AggregationProcess`](../../../tff/templates/AggregationProcess). ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|-------------|----------------------------------|\n| `TypeError` | If any argument type mismatches. |\n\n\u003cbr /\u003e"]]