Class SGD


public final class SGD extends Optimizer
Stochastic gradient descent with optional (Nesterov) momentum and L2 weight decay, as in PyTorch.
  • Constructor Details

    • SGD

      public SGD(List<Tensor> params, float lr)
      Plain SGD: no momentum, no weight decay.
    • SGD

      public SGD(List<Tensor> params, float lr, float momentum, float weightDecay, boolean nesterov)
      SGD with the given momentum (0 for none), L2 weight decay, and Nesterov momentum when nesterov is set.
  • Method Details

    • step

      public void step()
      Description copied from class: Optimizer
      Records one update of every parameter that has a gradient.
      Specified by:
      step in class Optimizer
    • state

      protected Map<String,Tensor[]> state()
      Description copied from class: Optimizer
      Per-parameter state by slot name, each array indexed like the parameters (null where none).
      Overrides:
      state in class Optimizer