class_docstr: Gradient descent (with momentum) optimizer.
  
  Update rule for parameter `w` with gradient `g` when `momentum` is 0:
  
  ```python
  w = w - learning_rate * g
  ```
  
  Update rule when `momentum` is larger than 0:
  
  ```python
  velocity = momentum * velocity - learning_rate * g
  w = w + velocity
  ```
  
  When `nesterov=True`, this rule becomes:
  
  ```python
  velocity = momentum * velocity - learning_rate * g
  w = w + momentum * velocity - learning_rate * g
  ```
  
  Args:
      learning_rate: A float, a
          `keras.optimizers.schedules.LearningRateSchedule` instance, or
          a callable that takes no arguments and returns the actual value to
          use. The learning rate. Defaults to `0.01`.
      momentum: float hyperparameter >= 0 that accelerates gradient descent in
          the relevant direction and dampens oscillations. 0 is vanilla
          gradient descent. Defaults to `0.0`.
      nesterov: boolean. Whether to apply Nesterov momentum.
          Defaults to `False`.
      {{base_optimizer_keyword_args}}
code: def __init__(
      self,
      learning_rate=0.01,
      momentum=0.0,
      nesterov=False,
      weight_decay=None,
      clipnorm=None,
      clipvalue=None,
      global_clipnorm=None,
      use_ema=False,
      ema_momentum=0.99,
      ema_overwrite_frequency=None,
      name="SGD",
      **kwargs,
  ):
      super().__init__(
          learning_rate=learning_rate,
          name=name,
          weight_decay=weight_decay,
          clipnorm=clipnorm,
          clipvalue=clipvalue,
          global_clipnorm=global_clipnorm,
          use_ema=use_ema,
          ema_momentum=ema_momentum,
          ema_overwrite_frequency=ema_overwrite_frequency,
          **kwargs,
      )
      if (
          not isinstance(momentum, float)
          or momentum < 0
          or momentum > 1
      ):
          raise ValueError("`momentum` must be a float between [0, 1].")
      self.momentum = momentum
      self.nesterov = nesterov
  
file_path: keras/keras/optimizers/sgd.py
imports: from keras import ops
  from keras.api_export import keras_export
  from keras.optimizers import optimizer
label_desc: Use image node_id 1 to create a new SGD object from inherited base classes: optimizer with example: obj = SGD(learning_rate, momentum, nesterov, weight_decay, clipnorm, clipvalue, global_clipnorm, use_ema, ema_momentum, ema_overwrite_frequency, name)