tff.learning.metrics.SumThenFinalizeFactory
Stay organized with collections
Save and categorize content based on your preferences.
Aggregation Factory that sums and then finalizes the metrics.
Inherits From: UnweightedAggregationFactory
tff.learning.metrics.SumThenFinalizeFactory(
metric_finalizers: tff.learning.metrics.MetricFinalizersType
,
initial_unfinalized_metrics: Optional[collections.OrderedDict[str, Any]] = None,
inner_summation_factory: Optional[tff.aggregators.UnweightedAggregationFactory
] = None
)
The created tff.templates.AggregationProcess
uses the inner summation
process created by the inner summation factory to sum unfinalized metrics
from tff.CLIENTS
to tff.SERVER
, accumulates the summed unfinalized metrics
in the state
, and then finalize the metrics for both current round and total
rounds. If the inner summation factory is not specified,
tff.aggregators.SumFactory
is used by default. The inner summation factory
can also use SecAgg.
The accumulated unfinalized metrics across rounds are initialized to be the
intial value of the unfinalized metrics, if the inital value is not specified,
zero is used.
The next
function of the created tff.templates.AggregationProcess
takes
the state
and local unfinalized metrics reported from tff.CLIENTS
, and
returns a tff.templates.MeasuredProcessOutput
object with the following
properties:
state
: a tuple of the state
of the inner summation process and the
accumulated unfinalized metrics across rounds.
result
: a tuple of the finalized metrics of the current round and total
rounds.
measurements
: the measurements of the inner summation process.
Args |
metric_finalizers
|
An collections.OrderedDict of metric names to
finalizers, should have same keys as the unfinalized metrics. A
finalizer is a function (typically a tf.function decorated callable or
a tff.tensorflow.computation decorated TFF Computation) that takes in
a metric's unfinalized values, and returns the finalized metric values.
This can be obtained from
tff.learning.models.VariableModel.metric_finalizers() .
|
initial_unfinalized_metrics
|
Optional. An collections.OrderedDict of
metric names to the initial values of local unfinalized metrics, its
structure should match that of local_unfinalized_metrics_type . If not
specified, defaults to zero.
|
inner_summation_factory
|
Optional. A
tff.aggregators.UnweightedAggregationFactory that creates a
tff.templates.AggregationProcess to sum the metrics from clients to
server. If not specified, tff.aggregators.SumFactory is used. If the
metrics aggregation needs SecAgg, aggregation_factory.SecureSumFactory
can be used as the inner summation factory.
|
Raises |
TypeError
|
If any argument type mismatches.
|
Methods
create
View source
create(
local_unfinalized_metrics_type: tff.types.StructWithPythonType
) -> tff.templates.AggregationProcess
Creates a tff.templates.AggregationProcess
for metrics aggregation.
Raises |
TypeError
|
If any argument type mismatches; if the metric finalizers
mismatch the type of local unfinalized metrics; if the initial
unfinalized metrics mismatch the type of local unfinalized metrics.
|
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.SumThenFinalizeFactory\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 sums and then finalizes the metrics.\n\nInherits From: [`UnweightedAggregationFactory`](../../../tff/aggregators/UnweightedAggregationFactory) \n\n tff.learning.metrics.SumThenFinalizeFactory(\n metric_finalizers: ../../../tff/learning/metrics/MetricFinalizersType,\n initial_unfinalized_metrics: Optional[collections.OrderedDict[str, Any]] = None,\n inner_summation_factory: Optional[../../../tff/aggregators/UnweightedAggregationFactory] = None\n )\n\nThe created [`tff.templates.AggregationProcess`](../../../tff/templates/AggregationProcess) uses the inner summation\nprocess created by the inner summation factory to sum unfinalized metrics\nfrom [`tff.CLIENTS`](../../../tff#CLIENTS) to [`tff.SERVER`](../../../tff#SERVER), accumulates the summed unfinalized metrics\nin the `state`, and then finalize the metrics for both current round and total\nrounds. If the inner summation factory is not specified,\n[`tff.aggregators.SumFactory`](../../../tff/aggregators/SumFactory) is used by default. The inner summation factory\ncan also use SecAgg.\n\nThe accumulated unfinalized metrics across rounds are initialized to be the\nintial value of the unfinalized metrics, if the inital value is not specified,\nzero is used.\n\nThe `next` function of the created [`tff.templates.AggregationProcess`](../../../tff/templates/AggregationProcess) takes\nthe `state` and local unfinalized metrics reported from [`tff.CLIENTS`](../../../tff#CLIENTS), and\nreturns a [`tff.templates.MeasuredProcessOutput`](../../../tff/templates/MeasuredProcessOutput) object with the following\nproperties:\n\n- `state`: a tuple of the `state` of the inner summation process and the accumulated unfinalized metrics across rounds.\n- `result`: a tuple of the finalized metrics of the current round and total rounds.\n- `measurements`: the measurements of the inner summation process.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `metric_finalizers` | An `collections.OrderedDict` of metric names to finalizers, should have same keys as the unfinalized metrics. A finalizer is a function (typically a [`tf.function`](https://www.tensorflow.org/api_docs/python/tf/function) decorated callable or a [`tff.tensorflow.computation`](../../../tff/tensorflow/computation) decorated TFF Computation) that takes in a metric's unfinalized values, and returns the finalized metric values. This can be obtained from [`tff.learning.models.VariableModel.metric_finalizers()`](../../../tff/learning/models/VariableModel#metric_finalizers). |\n| `initial_unfinalized_metrics` | Optional. An `collections.OrderedDict` of metric names to the initial values of local unfinalized metrics, its structure should match that of `local_unfinalized_metrics_type`. If not specified, defaults to zero. |\n| `inner_summation_factory` | Optional. A [`tff.aggregators.UnweightedAggregationFactory`](../../../tff/aggregators/UnweightedAggregationFactory) that creates a [`tff.templates.AggregationProcess`](../../../tff/templates/AggregationProcess) to sum the metrics from clients to server. If not specified, [`tff.aggregators.SumFactory`](../../../tff/aggregators/SumFactory) is used. If the metrics aggregation needs SecAgg, `aggregation_factory.SecureSumFactory` can be used as the inner summation factory. |\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\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 a [`tff.templates.AggregationProcess`](../../../tff/templates/AggregationProcess) for metrics aggregation.\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; if the metric finalizers mismatch the type of local unfinalized metrics; if the initial unfinalized metrics mismatch the type of local unfinalized metrics. |\n\n\u003cbr /\u003e"]]