code: def amsgrad(
      loss_or_grads,
      params,
      learning_rate=0.001,
      beta1=0.9,
      beta2=0.999,
      epsilon=1e-8,
  ):
      """AMSGrad updates
  
      AMSGrad updates implemented as in [1]_.
  
      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
          Learning rate
      beta1 : float or symbolic scalar
          Exponential decay rate for the first moment estimates.
      beta2 : float or symbolic scalar
          Exponential decay rate for the second moment estimates.
      epsilon : float or symbolic scalar
          Constant for numerical stability.
  
      Returns
      -------
      OrderedDict
          A dictionary mapping each parameter to its update expression
  
      References
      ----------
      .. [1] https://openreview.net/forum?id=ryQu7f-RZ
      """
      all_grads = get_or_compute_grads(loss_or_grads, params)
      t_prev = theano.shared(utils.floatX(0.0))
      updates = OrderedDict()
  
      # Using theano constant to prevent upcasting of float32
      one = T.constant(1)
  
      t = t_prev + 1
      a_t = (
          learning_rate * T.sqrt(one - beta2**t) / (one - beta1**t)
      )
  
      for param, g_t in zip(params, all_grads):
          value = param.get_value(borrow=True)
          m_prev = theano.shared(
              np.zeros(value.shape, dtype=value.dtype),
              broadcastable=param.broadcastable,
          )
          v_prev = theano.shared(
              np.zeros(value.shape, dtype=value.dtype),
              broadcastable=param.broadcastable,
          )
          v_hat_prev = theano.shared(
              np.zeros(value.shape, dtype=value.dtype),
              broadcastable=param.broadcastable,
          )
  
          m_t = beta1 * m_prev + (one - beta1) * g_t
          v_t = beta2 * v_prev + (one - beta2) * g_t**2
          v_hat_t = T.maximum(v_hat_prev, v_t)
          step = a_t * m_t / (T.sqrt(v_hat_t) + epsilon)
  
          updates[m_prev] = m_t
          updates[v_prev] = v_t
          updates[v_hat_prev] = v_hat_t
          updates[param] = param - step
  
      updates[t_prev] = t
      return updates
  
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 12 for calling a global function with example usage: amsgrad(loss_or_grads, params, learning_rate, beta1, beta2, epsilon) and returns: updates