INNER CODE UNIT · Python

_compute_gradients

horovod/horovod · horovod/_keras/__init__.py:106

        def _compute_gradients(self, loss, var_list, grad_loss=None, tape=None):
            """
            Compute gradients of all trainable variables.

            See Optimizer.get_gradients() for more info.

            In DistributedOptimizer, get_gradients() is overriden to also
            allreduce the gradients before returning them.
            """
            base_class = super(self.__class__, self)
            if _PRE_TF_2_4_0:
                return base_class._compute_gradients(
                    loss, var_list, grad_loss, tape)

            tape = tf.GradientTape() if tape is None else tape
            if hasattr(base_class, '_compute_gradients'):
                grads_and_vars = base_class._compute_gradients(
                    # pylint: disable=protected-access

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…