The returned federated TFF computation is a polymorphic computation that
accepts unfinalized client metrics, and returns finalized, summed metrics
placed at the server. Invoking the polymorphic computation will initiate
tracing on the argument and will raise a ValueError if the keys (i.e.,
metric names) in metric_finalizers are not the same as those of the argument
the polymorphic method is invoked on.
[null,null,["Last updated 2024-09-20 UTC."],[],[],null,["# tff.learning.metrics.sum_then_finalize\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 a TFF computation that aggregates metrics via `sum_then_finalize`. \n\n tff.learning.metrics.sum_then_finalize(\n metric_finalizers: Union[../../../tff/learning/metrics/MetricFinalizersType, ../../../tff/learning/metrics/FunctionalMetricFinalizersType],\n local_unfinalized_metrics_type: Optional[../../../tff/types/StructWithPythonType] = None\n ) -\u003e ../../../tff/Computation\n\nThe returned federated TFF computation is a polymorphic computation that\naccepts unfinalized client metrics, and returns finalized, summed metrics\nplaced at the server. Invoking the polymorphic computation will initiate\ntracing on the argument and will raise a `ValueError` if the keys (i.e.,\nmetric names) in `metric_finalizers` are not the same as those of the argument\nthe polymorphic method is invoked on.\n| **Note:** invoking this computation outside of a federated context (a method decorated with [`tff.federated_computation`](../../../tff/federated_computation)) will require first wrapping it in a concrete, non-polymorphic [`tff.Computation`](../../../tff/Computation) with appropriate federated types.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `metric_finalizers` | Either the result of [`tff.learning.models.VariableModel.metric_finalizers`](../../../tff/learning/models/VariableModel#metric_finalizers) (an `OrderedDict` of callables) or the [`tff.learning.models.FunctionalModel.finalize_metrics`](../../../tff/learning/models/FunctionalModel#finalize_metrics) method (a callable that takes an `OrderedDict` argument). If the former, the keys must be the same as the `OrderedDict` returned by [`tff.learning.models.VariableModel.report_local_unfinalized_metrics`](../../../tff/learning/models/VariableModel#report_local_unfinalized_metrics). If the later, the callable must compute over the same keyspace of the result returned by [`tff.learning.models.FunctionalModel.update_metrics_state`](../../../tff/learning/models/FunctionalModel#update_metrics_state). |\n| `local_unfinalized_metrics_type` | Unused, will be removed from the API in the future. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A federated TFF computation that sums the unfinalized metrics from `CLIENTS`, and applies the correponding finalizers at `SERVER`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|---------------------------------------|\n| `TypeError` | If the inputs are of the wrong types. |\n\n\u003cbr /\u003e"]]