# orbit.utils.SummaryManager

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/orbit/utils/summary_manager.py#L24-L112) |

A utility class for managing summary writing.

Inherits From: [`SummaryManagerInterface`](https://www.tensorflow.org/api_docs/python/orbit/utils/SummaryManagerInterface)

    orbit.utils.SummaryManager(
        summary_dir, summary_fn, global_step=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `summary_dir` | The directory in which to write summaries. If `None`, all summary writing operations provided by this class are no-ops. |
| `summary_fn` | A callable defined accepting `name`, `value`, and `step` parameters, making calls to [`tf.summary`](https://www.tensorflow.org/api_docs/python/tf/summary) functions to write summaries. |
| `global_step` | A [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable) containing the global step value. |

<br />

## Methods

### `flush`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/orbit/utils/summary_manager.py#L64-L67)

    flush()

Flushes the underlying summary writers.

### `summary_writer`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/orbit/utils/summary_manager.py#L47-L62)

    summary_writer(
        relative_path=''
    )

Returns the underlying summary writer for a specific subdirectory.

<br />

<br />

<br />

| Args ||
|---|---|
| `relative_path` | The current path in which to write summaries, relative to the summary directory. By default it is empty, which corresponds to the root directory. |

<br />

### `write_summaries`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/orbit/utils/summary_manager.py#L69-L103)

    write_summaries(
        summary_dict
    )

Writes summaries for the given dictionary of values.

This recursively creates subdirectories for any nested dictionaries
provided in `summary_dict`, yielding a hierarchy of directories which will
then be reflected in the TensorBoard UI as different colored curves.

For example, users may evaluate on multiple datasets and return
`summary_dict` as a nested dictionary:

    {
        "dataset1": {
            "loss": loss1,
            "accuracy": accuracy1
        },
        "dataset2": {
            "loss": loss2,
            "accuracy": accuracy2
        },
    }

This will create two subdirectories, "dataset1" and "dataset2", inside the
summary root directory. Each directory will contain event files including
both "loss" and "accuracy" summaries.

<br />

<br />

<br />

| Args ||
|---|---|
| `summary_dict` | A dictionary of values. If any value in `summary_dict` is itself a dictionary, then the function will create a subdirectory with name given by the corresponding key. This is performed recursively. Leaf values are then summarized using the summary writer instance specific to the parent relative path. |

<br />