tff.learning.programs.extract_and_rewrap_metrics
Stay organized with collections
Save and categorize content based on your preferences.
Extracts a sub-structure and re-wraps it with a new prefix.
tff.learning.programs.extract_and_rewrap_metrics(
metrics_structure: Mapping[str, Any], *, path: Sequence[str]
) -> Mapping[str, Any]
This is used to normalize outputs from the training and evaluation
computations. For example, we are interested in the following substructure
from the evaluation and training tasks:
client_work/eval/current_round_metrics/...
client_work/eval/total_rounds_metrics/...
client_work/train/...
And we like to "re-home" these structures under:
model_metrics/...
while leaving all the other metrics alone. This can be thought of as a
"subtree promotion" method.
This is used for grouping metrics so that they appear aligned in
http://tensorboard/ in a uniform way. TensorBoard uses the name up to the
first /
as a tab separator in the UI.
Args |
metrics_structure
|
The nested structure of tensor-like metric values.
|
path
|
A sequence of strings that will be used to traverse the keys of
metrics_structure and identify the substructure of interest.
|
Returns |
A structure of metrics of metrics_substructure .
|
Raises |
ValueError
|
If path is empty.
|
KeyError
|
If any key in path sequence does not exist in the
metrics_structure .
|
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.programs.extract_and_rewrap_metrics\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\nExtracts a sub-structure and re-wraps it with a new prefix. \n\n tff.learning.programs.extract_and_rewrap_metrics(\n metrics_structure: Mapping[str, Any], *, path: Sequence[str]\n ) -\u003e Mapping[str, Any]\n\nThis is used to normalize outputs from the training and evaluation\ncomputations. For example, we are interested in the following substructure\nfrom the evaluation and training tasks: \n\n client_work/eval/current_round_metrics/...\n client_work/eval/total_rounds_metrics/...\n client_work/train/...\n\nAnd we like to \"re-home\" these structures under: \n\n model_metrics/...\n\nwhile leaving all the other metrics alone. This can be thought of as a\n\"subtree promotion\" method.\n\nThis is used for grouping metrics so that they appear aligned in\n\u003chttp://tensorboard/\u003e in a uniform way. TensorBoard uses the name up to the\nfirst `/` as a tab separator in the UI.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------------|--------------------------------------------------------------------------------------------------------------------------------|\n| `metrics_structure` | The nested structure of tensor-like metric values. |\n| `path` | A sequence of strings that will be used to traverse the keys of `metrics_structure` and identify the substructure of interest. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A structure of metrics of `metrics_substructure`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|--------------------------------------------------------------------------|\n| `ValueError` | If `path` is empty. |\n| `KeyError` | If any key in `path` sequence does not exist in the `metrics_structure`. |\n\n\u003cbr /\u003e"]]