484ffb3eae65a09c717a6c823dcc888d5750df6c,sonnet/src/momentum.py,Momentum,apply,#Momentum#Any#Any#,67

Before Change


    self._initialize(parameters)
    for update, parameter, momentum in zip(updates, parameters,
                                           self.accumulated_momentum):
      if update is not None:
        optimizer_utils.check_same_dtype(update, parameter)
        lr = tf.cast(self.learning_rate, update.dtype)
        mu = tf.cast(self.momentum, update.dtype)
        if isinstance(update, tf.IndexedSlices):
          update, indices = optimizer_utils.deduplicate_indexed_slices(
              update.values, update.indices)
          sparse_momentum_update = (mu * momentum.sparse_read(indices)) + update
          momentum.scatter_update(
              tf.IndexedSlices(sparse_momentum_update, indices))
          if self.use_nesterov:
            parameter.scatter_sub(
                tf.IndexedSlices(
                    (lr * update) + (lr * mu * sparse_momentum_update),
                    indices))
          else:
            parameter.scatter_sub(
                tf.IndexedSlices(lr * sparse_momentum_update, indices))
        else:
          momentum.assign((mu * momentum) + update)
          if self.use_nesterov:
            parameter.assign_sub((lr * update) + (lr * mu * momentum))
          else:
            parameter.assign_sub(lr * momentum)


class FastMomentum(base.Optimizer):
  SGD with Momentum module.

  def __init__(self,

After Change



      else:
        // Compute and apply a dense update.
        update, momentum = momentum_update(update, learning_rate, mu,
                                           momentum_var, self.use_nesterov)
        momentum_var.assign(momentum)
        param.assign_sub(update)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: deepmind/sonnet
Commit Name: 484ffb3eae65a09c717a6c823dcc888d5750df6c
Time: 2019-10-16
Author: tomhennigan@google.com
File Name: sonnet/src/momentum.py
Class Name: Momentum
Method Name: apply


Project Name: NVIDIA/OpenSeq2Seq
Commit Name: 361d87cc6d4fe86c82204becce00f4d595e1c459
Time: 2019-01-09
Author: jasoli@nvidia.com
File Name: open_seq2seq/utils/helpers.py
Class Name:
Method Name: _restore_embed


Project Name: ray-project/ray
Commit Name: 83e06cd30a45245c2cb0e9f4bd924224b1581554
Time: 2020-03-01
Author: sven@anyscale.io
File Name: rllib/agents/ddpg/ddpg_policy.py
Class Name: DDPGTFPolicy
Method Name: __init__