View source on GitHub
|
A conditional accumulator for aggregating sparse gradients.
Inherits From: ConditionalAccumulatorBase
tf.compat.v1.SparseConditionalAccumulator(
dtype,
shape=None,
shared_name=None,
name='sparse_conditional_accumulator',
reduction_type='MEAN'
)
Sparse gradients are represented by IndexedSlices.
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.
dtype
shape
shared_name
name
reduction_type
accumulator_ref
dtype
name
apply_gradapply_grad(
grad_indices, grad_values, grad_shape=None, local_step=0, name=None
)
Attempts to apply a sparse 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.
A sparse gradient is represented by its indices, values and possibly empty or None shape. Indices must be a vector representing the locations of non-zero entries in the tensor. Values are the non-zero slices of the gradient, and must have the same first dimension as indices, i.e., the nnz represented by indices and values must be consistent. Shape, if not empty or None, must be consistent with the accumulator's shape (if also provided).
grad_indices
grad_values
grad_shape
local_step
name
InvalidArgumentError
apply_indexed_slices_gradapply_indexed_slices_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.
grad
IndexedSlices to be applied.
local_step
name
InvalidArgumentError
num_accumulatednum_accumulated(
name=None
)
Number of gradients that have currently been aggregated in accumulator.
name
set_global_stepset_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.
new_global_step
name
take_gradtake_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:
num_required
name
InvalidArgumentError
num_required < 1
take_indexed_slices_gradtake_indexed_slices_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:
num_required
name
IndexedSlices holding the value of the average gradient.
InvalidArgumentError
num_required < 1
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. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.