Class Momentum

java.lang.Object
org.tensorflow.framework.optimizers.Optimizer
org.tensorflow.framework.optimizers.Momentum

public class Momentum extends Optimizer
Stochastic gradient descent plus momentum, either nesterov or traditional.

See the paper for details of nesterov momentum.

  • Field Details

  • Constructor Details

    • Momentum

      public Momentum(Graph graph)
      Creates a Momentum Optimizer
      Parameters:
      graph - the TensorFlow graph
    • Momentum

      public Momentum(Graph graph, float learningRate)
      Creates a Momentum Optimizer
      Parameters:
      graph - the TensorFlow graph
      learningRate - the learning rate
    • Momentum

      public Momentum(Graph graph, float learningRate, float momentum)
      Creates a Momentum Optimizer
      Parameters:
      graph - the TensorFlow graph
      learningRate - the learning rate
      momentum - hyperparameter that accelerates gradient descent in the relevant direction and dampens oscillations, Must be greater than or equal to zero. Default is 0.
    • Momentum

      public Momentum(Graph graph, float learningRate, float momentum, boolean useNesterov)
      Creates a Momentum Optimizer
      Parameters:
      graph - the TensorFlow graph
      learningRate - the learning rate
      momentum - hyperparameter that accelerates gradient descent in the relevant direction and dampens oscillations, Must be greater than or equal to zero. Default is 0.
      useNesterov - Whether to apply Nesterov momentum. Defaults to false.
    • Momentum

      public Momentum(Graph graph, String name, float learningRate, float momentum, boolean useNesterov)
      Creates a Momentum Optimizer
      Parameters:
      graph - the TensorFlow graph
      name - the name for this Optimizer
      learningRate - the learning rate
      momentum - hyperparameter that accelerates gradient descent in the relevant direction and dampens oscillations, Must be greater than or equal to zero. Default is 0.
      useNesterov - Whether to apply Nesterov momentum. Defaults to false.
  • Method Details

    • createSlots

      protected void createSlots(List<Output<? extends TType>> variables)
      Performs a No-op slot creation method.
      Overrides:
      createSlots in class Optimizer
      Parameters:
      variables - The variables to create slots for.
    • applyDense

      protected <T extends TType> Op applyDense(Ops deps, Output<T> gradient, Output<T> variable)
      Generates the gradient update operations for the specific variable and gradient.
      Specified by:
      applyDense in class Optimizer
      Type Parameters:
      T - The type of the variable.
      Parameters:
      gradient - The gradient to use.
      variable - The variable to update.
      Returns:
      An operand which applies the desired optimizer update to the variable.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getOptimizerName

      public String getOptimizerName()
      Get the Name of the optimizer.
      Specified by:
      getOptimizerName in class Optimizer
      Returns:
      The optimizer name.