tf.AggregationMethod  |  TensorFlow v2.16.1 (original) (raw)

tf.AggregationMethod

Stay organized with collections Save and categorize content based on your preferences.

A class listing aggregation methods used to combine gradients.

View aliases

Compat aliases for migration

SeeMigration guide for more details.

tf.compat.v1.AggregationMethod

Computing partial derivatives can require aggregating gradient contributions. This class lists the various methods that can be used to combine gradients in the graph.

The following aggregation methods are part of the stable API for aggregating gradients:

The following aggregation methods are experimental and may not be supported in future releases:

Example usage when computing gradient:

@tf.function def example(): x = tf.constant(1.0) y = x * 2.0 z = y + y + y + y return tf.gradients(z, [x, y], aggregation_method=tf.AggregationMethod.EXPERIMENTAL_ACCUMULATE_N) example() [<tf.Tensor: shape=(), dtype=float32, numpy=8.0>, <tf.Tensor: shape=(), dtype=float32, numpy=4.0>]

Class Variables
ADD_N 0
DEFAULT 0
EXPERIMENTAL_ACCUMULATE_N 2
EXPERIMENTAL_TREE 1