public class Adam<Model: Layer>: Optimizer
    where Model.AllDifferentiableVariables == Model.CotangentVector

Adam optimizer.

Reference: Adam - A Method for Stochastic Optimization

  • The learning rate.

    Declaration

    public var learningRate: Float
  • A coefficient used to calculate the first and second moments of gradients.

    Declaration

    public var beta1: Float
  • A coefficient used to calculate the first and second moments of gradients.

    Declaration

    public var beta2: Float
  • A small scalar added to the denominator to improve numerical stability.

    Declaration

    public var epsilon: Float
  • The weight decay.

    Declaration

    public var decay: Float
  • The current step.

    Declaration

    public var step: Int
  • The first moments of the weights.

    Declaration

    public var firstMoments: Model.AllDifferentiableVariables
  • The second moments of the weights.

    Declaration

    public var secondMoments: Model.AllDifferentiableVariables
  • Declaration

    public init(
        for model: __shared Model,
        learningRate: Float = 1e-3,
        beta1: Float = 0.9,
        beta2: Float = 0.999,
        epsilon: Float = 1e-8,
        decay: Float = 0
    )
  • Declaration

    public func update(_ model: inout Model.AllDifferentiableVariables,
                       along direction: Model.AllDifferentiableVariables)