code: def momentum(loss_or_grads, params, learning_rate, momentum=0.9):
      """Stochastic Gradient Descent (SGD) updates with momentum
  
      Generates update expressions of the form:
  
      * ``velocity := momentum * velocity - learning_rate * gradient``
      * ``param := param + velocity``
  
      Parameters
      ----------
      loss_or_grads : symbolic expression or list of expressions
          A scalar loss expression, or a list of gradient expressions
      params : list of shared variables
          The variables to generate update expressions for
      learning_rate : float or symbolic scalar
          The learning rate controlling the size of update steps
      momentum : float or symbolic scalar, optional
          The amount of momentum to apply. Higher momentum results in
          smoothing over more update steps. Defaults to 0.9.
  
      Returns
      -------
      OrderedDict
          A dictionary mapping each parameter to its update expression
  
      Notes
      -----
      Higher momentum also results in larger update steps. To counter that,
      you can optionally scale your learning rate by `1 - momentum`.
  
      See Also
      --------
      apply_momentum : Generic function applying momentum to updates
      nesterov_momentum : Nesterov's variant of SGD with momentum
      """
      updates = sgd(loss_or_grads, params, learning_rate)
      return apply_momentum(updates, momentum=momentum)
  
file_path: Lasagne/lasagne/updates.py
imports: from collections import OrderedDict
  import numpy
  import theano
  import theano.tensor
  from .None import utils
label_desc: Use image node_id 4 for calling a global function with example usage: momentum(loss_or_grads, params, learning_rate, momentum) and returns: apply_momentum