# tf_agents.utils.common.periodically

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/utils/common.py#L415-L448) |

Periodically performs the tensorflow op in `body`.

    tf_agents.utils.common.periodically(
        body, period, name='periodically'
    )

The body tensorflow op will be executed every `period` times the periodically
op is executed. More specifically, with `n` the number of times the op has
been executed, the body will be executed when `n` is a non zero positive
multiple of `period` (i.e. there exist an integer `k > 0` such that
`k * period == n`).

If `period` is `None`, it will not perform any op and will return a
[`tf.no_op()`](https://www.tensorflow.org/api_docs/python/tf/no_op).

If `period` is 1, it will just execute the body, and not create any counters
or conditionals.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `body` | callable that returns the tensorflow op to be performed every time an internal counter is divisible by the period. The op must have no output (for example, a tf.group()). |
| `period` | inverse frequency with which to perform the op. |
| `name` | name of the variable_scope. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | if body is not a callable. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| An op that periodically performs the specified op. ||

<br />