docstr: Update weights ws of some function, given the derivatives of some
  cost c with respect to ws, using ADAM update. `[reference]
  
  <https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam>`_
  
  Parameters
  ----------
  self
      Weights of the function to be updated.
  dcdw
      Derivates of the cost c with respect to the weights ws, [dc/dw for w in ws].
  lr
      Learning rate(s), the rate(s) at which the weights should be updated
      relative to the gradient.
  mw_tm1
      running average of the gradients, from the previous time-step.
  vw_tm1
      running average of second moments of the gradients, from the previous
      time-step.
  step
      training step.
  beta1
      gradient forgetting factor (Default value = 0.9).
  beta2
      second moment of gradient forgetting factor (Default value = 0.999).
  epsilon
      divisor during adam update, preventing division by zero
      (Default value = 1e-7).
  stop_gradients
      Whether to stop the gradients of the variables after each gradient step.
      Default is ``True``.
  out
      optional output container, for writing the result to. It must have a shape
      that the inputs broadcast to.
  
  Returns
  -------
  ret
      The new function weights ws_new, and also new mw and vw, following the adam
      updates.
  
  Examples
  --------
  With one :class:`ivy.Container` inputs:
  
  >>> w = ivy.Container(a=ivy.array([1., 2., 3.]), b=ivy.array([4., 5., 6.]))
  >>> dcdw = ivy.array([1., 0.2, 0.4])
  >>> mw_tm1 = ivy.array([0., 0., 0.])
  >>> vw_tm1 = ivy.array([0.])
  >>> lr = ivy.array(0.01)
  >>> step = 2
  >>> updated_weights = w.adam_update(dcdw, mw_tm1, vw_tm1, lr, step)
  >>> print(updated_weights)
  ({
      a: ivy.array([1., 2., 3.]),
      b: ivy.array([4., 5., 6.])
  }, ivy.array([0.1 , 0.02, 0.04]), ivy.array([0.01099, 0.01003, 0.01015]))
  
  With multiple :class:`ivy.Container` inputs:
  
  >>> x = ivy.Container(a=ivy.array([0., 1., 2.]),
  ...                   b=ivy.array([3., 4., 5.]))
  >>> dcdw = ivy.Container(a=ivy.array([0.1,0.3,0.3]),
  ...                      b=ivy.array([0.3,0.2,0.2]))
  >>> lr = ivy.array(0.001)
  >>> mw_tm1 = ivy.Container(a=ivy.array([0.,0.,0.]),
  ...                        b=ivy.array([0.,0.,0.]))
  >>> vw_tm1 = ivy.Container(a=ivy.array([0.,]),
  ...                        b=ivy.array([0.,]))
  >>> step = 3
  >>> beta1 = 0.9
  >>> beta2 = 0.999
  >>> epsilon = 1e-7
  >>> stop_gradients = False
  >>> updated_weights = w.adam_update(dcdw, lr, mw_tm1, vw_tm1, step, beta1=beta1,
  ...                                beta2=beta2, epsilon=epsilon,
  ...                                stop_gradients=stop_gradients)
  >>> print(updated_weights)
  ({
      a: ivy.array([0.99936122, 1.99936116, 2.99936128]),
      b: ivy.array([3.99936128, 4.99936104, 5.99936104])
  }, {
      a: ivy.array([0.01, 0.03, 0.03]),
      b: ivy.array([0.03, 0.02, 0.02])
  }, {
      a: ivy.array([1.00000016e-05, 9.00000086e-05, 9.00000086e-05]),
      b: ivy.array([9.00000086e-05, 4.00000063e-05, 4.00000063e-05])
  })
docstr_tok: ["Update","weights","ws","of","some","function",",","given","the","derivatives","of","some","cost","c","with","respect","to","ws",",","using","ADAM","update",".","`","[","reference","]","<","https",":","\/\/en.wikipedia.org\/wiki\/Stochastic_gradient_descent","#","Adam",">","`","_","Parameters","--","--","--","--","--","self","Weights","of","the","function","to","be","updated",".","dcdw","Derivates","of","the","cost","c","with","respect","to","the","weights","ws",",","[","dc\/dw","for","w","in","ws","]",".","lr","Learning","rate","(","s",")",",","the","rate","(","s",")","at","which","the","weights","should","be","updated","relative","to","the","gradient",".","mw_tm1","running","average","of","the","gradients",",","from","the","previous","time-step",".","vw_tm1","running","average","of","second","moments","of","the","gradients",",","from","the","previous","time-step",".","step","training","step",".","beta1","gradient","forgetting","factor","(","Default","value","=","0.9",")",".","beta2","second","moment","of","gradient","forgetting","factor","(","Default","value","=","0.999",")",".","epsilon","divisor","during","adam","update",",","preventing","division","by","zero","(","Default","value","=","1e-7",")",".","stop_gradients","Whether","to","stop","the","gradients","of","the","variables","after","each","gradient","step",".","Default","is","``","True","``",".","out","optional","output","container",",","for","writing","the","result","to",".","It","must","have","a","shape","that","the","inputs","broadcast","to",".","Returns","--","--","--","-","ret","The","new","function","weights","ws_new",",","and","also","new","mw","and","vw",",","following","the","adam","updates",".","Examples","--","--","--","--","With","one",":","class",":","`","ivy.Container","`","inputs",":",">",">",">","w","=","ivy.Container","(","a=ivy.array","(","[","1.",",","2.",",","3",".","]",")",",","b=ivy.array","(","[","4.",",","5.",",","6",".","]",")",")",">",">",">","dcdw","=","ivy.array","(","[","1.",",","0.2",",","0.4","]",")",">",">",">","mw_tm1","=","ivy.array","(","[","0.",",","0.",",","0",".","]",")",">",">",">","vw_tm1","=","ivy.array","(","[","0",".","]",")",">",">",">","lr","=","ivy.array","(","0.01",")",">",">",">","step","=","2",">",">",">","updated_weights","=","w.adam_update","(","dcdw",",","mw_tm1",",","vw_tm1",",","lr",",","step",")",">",">",">","print","(","updated_weights",")","(","{","a",":","ivy.array","(","[","1.",",","2.",",","3",".","]",")",",","b",":","ivy.array","(","[","4.",",","5.",",","6",".","]",")","}",",","ivy.array","(","[","0.1",",","0.02",",","0.04","]",")",",","ivy.array","(","[","0.01099",",","0.01003",",","0.01015","]",")",")","With","multiple",":","class",":","`","ivy.Container","`","inputs",":",">",">",">","x","=","ivy.Container","(","a=ivy.array","(","[","0.",",","1.",",","2",".","]",")",",","...","b=ivy.array","(","[","3.",",","4.",",","5",".","]",")",")",">",">",">","dcdw","=","ivy.Container","(","a=ivy.array","(","[","0.1,0.3,0.3","]",")",",","...","b=ivy.array","(","[","0.3,0.2,0.2","]",")",")",">",">",">","lr","=","ivy.array","(","0.001",")",">",">",">","mw_tm1","=","ivy.Container","(","a=ivy.array","(","[","0.,0.,0",".","]",")",",","...","b=ivy.array","(","[","0.,0.,0",".","]",")",")",">",">",">","vw_tm1","=","ivy.Container","(","a=ivy.array","(","[","0.",",","]",")",",","...","b=ivy.array","(","[","0.",",","]",")",")",">",">",">","step","=","3",">",">",">","beta1","=","0.9",">",">",">","beta2","=","0.999",">",">",">","epsilon","=","1e-7",">",">",">","stop_gradients","=","False",">",">",">","updated_weights","=","w.adam_update","(","dcdw",",","lr",",","mw_tm1",",","vw_tm1",",","step",",","beta1=beta1",",","...","beta2=beta2",",","epsilon=epsilon",",","...","stop_gradients=stop_gradients",")",">",">",">","print","(","updated_weights",")","(","{","a",":","ivy.array","(","[","0.99936122",",","1.99936116",",","2.99936128","]",")",",","b",":","ivy.array","(","[","3.99936128",",","4.99936104",",","5.99936104","]",")","}",",","{","a",":","ivy.array","(","[","0.01",",","0.03",",","0.03","]",")",",","b",":","ivy.array","(","[","0.03",",","0.02",",","0.02","]",")","}",",","{","a",":","ivy.array","(","[","1.00000016e-05",",","9.00000086e-05",",","9.00000086e-05","]",")",",","b",":","ivy.array","(","[","9.00000086e-05",",","4.00000063e-05",",","4.00000063e-05","]",")","}",")"]
code: def adam_update(
      self: ivy.Container,
      dcdw: Union[ivy.Array, ivy.NativeArray, ivy.Container],
      lr: Union[float, ivy.Array, ivy.NativeArray, ivy.Container],
      mw_tm1: Union[ivy.Array, ivy.NativeArray, ivy.Container],
      vw_tm1: Union[ivy.Array, ivy.NativeArray, ivy.Container],
      step: Union[int, ivy.Container],
      /,
      *,
      beta1: Union[float, ivy.Container] = 0.9,
      beta2: Union[float, ivy.Container] = 0.999,
      epsilon: Union[float, ivy.Container] = 1e-7,
      stop_gradients: Union[bool, ivy.Container] = True,
      out: Optional[ivy.Container] = None,
  ) -> ivy.Container:
      """Update weights ws of some function, given the derivatives of some
      cost c with respect to ws, using ADAM update. `[reference]
  
      <https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam>`_
  
      Parameters
      ----------
      self
          Weights of the function to be updated.
      dcdw
          Derivates of the cost c with respect to the weights ws, [dc/dw for w in ws].
      lr
          Learning rate(s), the rate(s) at which the weights should be updated
          relative to the gradient.
      mw_tm1
          running average of the gradients, from the previous time-step.
      vw_tm1
          running average of second moments of the gradients, from the previous
          time-step.
      step
          training step.
      beta1
          gradient forgetting factor (Default value = 0.9).
      beta2
          second moment of gradient forgetting factor (Default value = 0.999).
      epsilon
          divisor during adam update, preventing division by zero
          (Default value = 1e-7).
      stop_gradients
          Whether to stop the gradients of the variables after each gradient step.
          Default is ``True``.
      out
          optional output container, for writing the result to. It must have a shape
          that the inputs broadcast to.
  
      Returns
      -------
      ret
          The new function weights ws_new, and also new mw and vw, following the adam
          updates.
  
      Examples
      --------
      With one :class:`ivy.Container` inputs:
  
      >>> w = ivy.Container(a=ivy.array([1., 2., 3.]), b=ivy.array([4., 5., 6.]))
      >>> dcdw = ivy.array([1., 0.2, 0.4])
      >>> mw_tm1 = ivy.array([0., 0., 0.])
      >>> vw_tm1 = ivy.array([0.])
      >>> lr = ivy.array(0.01)
      >>> step = 2
      >>> updated_weights = w.adam_update(dcdw, mw_tm1, vw_tm1, lr, step)
      >>> print(updated_weights)
      ({
          a: ivy.array([1., 2., 3.]),
          b: ivy.array([4., 5., 6.])
      }, ivy.array([0.1 , 0.02, 0.04]), ivy.array([0.01099, 0.01003, 0.01015]))
  
      With multiple :class:`ivy.Container` inputs:
  
      >>> x = ivy.Container(a=ivy.array([0., 1., 2.]),
      ...                   b=ivy.array([3., 4., 5.]))
      >>> dcdw = ivy.Container(a=ivy.array([0.1,0.3,0.3]),
      ...                      b=ivy.array([0.3,0.2,0.2]))
      >>> lr = ivy.array(0.001)
      >>> mw_tm1 = ivy.Container(a=ivy.array([0.,0.,0.]),
      ...                        b=ivy.array([0.,0.,0.]))
      >>> vw_tm1 = ivy.Container(a=ivy.array([0.,]),
      ...                        b=ivy.array([0.,]))
      >>> step = 3
      >>> beta1 = 0.9
      >>> beta2 = 0.999
      >>> epsilon = 1e-7
      >>> stop_gradients = False
      >>> updated_weights = w.adam_update(dcdw, lr, mw_tm1, vw_tm1, step, beta1=beta1,
      ...                                beta2=beta2, epsilon=epsilon,
      ...                                stop_gradients=stop_gradients)
      >>> print(updated_weights)
      ({
          a: ivy.array([0.99936122, 1.99936116, 2.99936128]),
          b: ivy.array([3.99936128, 4.99936104, 5.99936104])
      }, {
          a: ivy.array([0.01, 0.03, 0.03]),
          b: ivy.array([0.03, 0.02, 0.02])
      }, {
          a: ivy.array([1.00000016e-05, 9.00000086e-05, 9.00000086e-05]),
          b: ivy.array([9.00000086e-05, 4.00000063e-05, 4.00000063e-05])
      })
      """
      return ivy.adam_update(
          self,
          dcdw,
          lr,
          mw_tm1,
          vw_tm1,
          step,
          beta1=beta1,
          beta2=beta2,
          epsilon=epsilon,
          stop_gradients=stop_gradients,
          out=out,
      )
  
file_path: ivy/ivy/data_classes/container/gradients.py
imports: from typing import Optional, Union, List, Dict
  import ivy
  from ivy.data_classes.container.base import ContainerBase
label_desc: Use image node_id 7 for calling the _ContainerWithGradients obj's underlying member method code with example usage: obj.adam_update() and returns: ivy