tf.compat.v1.ConditionalAccumulator

View source on GitHub

A conditional accumulator for aggregating gradients.

Inherits From: ConditionalAccumulatorBase

tf.compat.v1.ConditionalAccumulator(
    dtype, shape=None, shared_name=None, name='conditional_accumulator',
    reduction_type='MEAN'
)

Up-to-date gradients (i.e., time step at which gradient was computed is equal to the accumulator's time step) are added to the accumulator.

Extraction of the average gradient is blocked until the required number of gradients has been accumulated.

Args:

Attributes:

Methods

apply_grad

View source

apply_grad(
    grad, local_step=0, name=None
)

Attempts to apply a gradient to the accumulator.

The attempt is silently dropped if the gradient is stale, i.e., local_step is less than the accumulator's global time step.

Args:

Returns:

The operation that (conditionally) applies a gradient to the accumulator.

Raises:

num_accumulated

View source

num_accumulated(
    name=None
)

Number of gradients that have currently been aggregated in accumulator.

Args:

Returns:

Number of accumulated gradients currently in accumulator.

set_global_step

View source

set_global_step(
    new_global_step, name=None
)

Sets the global time step of the accumulator.

The operation logs a warning if we attempt to set to a time step that is lower than the accumulator's own time step.

Args:

Returns:

Operation that sets the accumulator's time step.

take_grad

View source

take_grad(
    num_required, name=None
)

Attempts to extract the average gradient from the accumulator.

The operation blocks until sufficient number of gradients have been successfully applied to the accumulator.

Once successful, the following actions are also triggered:

Args:

Returns:

A tensor holding the value of the average gradient.

Raises: