Class Adam


  • public class Adam
    extends Optimizer
    Adam is a generalization of the AdaGrad Optimizer.

    Adam updates the weights using:

    \( m = beta1 * m + (1 - beta1) * grad\)
    \( v = beta2 * v + (1 - beta2) * grad^2 \)
    \( w -= learning_rate * m / (sqrt(v) + epsilon) \)

    where g represents the gradient, and m/v are 1st and 2nd order moment estimates (mean and variance).

    See Also:
    The D2L chapter on Adam
    • Constructor Detail

      • Adam

        protected Adam​(Adam.Builder builder)
        Creates a new instance of Adam optimizer.
        Parameters:
        builder - the builder to create a new instance of Adam optimizer
    • Method Detail

      • update

        public void update​(java.lang.String parameterId,
                           NDArray weight,
                           NDArray grad)
        Updates the parameters according to the gradients.
        Specified by:
        update in class Optimizer
        Parameters:
        parameterId - the parameter to be updated
        weight - the weights of the parameter
        grad - the gradients
      • builder

        public static Adam.Builder builder()
        Creates a builder to build a Adam.
        Returns:
        a new builder