Skip to content

Add the Adam optimizer from [Kingma et al., 2014](http://arxiv.org/abs/1412.6980). #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

Add the Adam optimizer from Kingma et al., 2014.

Some specific design decisions were made that differ from Keras/Optax.

  • Keras ignores the step-dependent bias correction for epsilon (optax and tensorflow's Adam optimizer's setting. google-deepmind/optax#571),
    which differs from the original paper. We do correct for the bias,
    consistent with optax/pytorch.
  • Keras/pytorch support amsgrad: bool as an option, which changes how the variable is
    updated, keeping track of the maximum velocity encountered. However, this
    would lead to an additional state parameter (v_max), and conditionally
    changes the number of slot variables. Slot variables are particularly
    expensive in large embedding lookups (each is the size of the entire
    sharded table), and would require a different underlying primitive anyways.
    If we need the option, we can create a new optimizer. This is consistent with optax,
    which has a separate optax.amsgrad optimizer.
  • Optax supports a nesterov: bool option. Similar to amsgrad, this modifies
    the update rule. Technically the Nesterov modification also adds a step-dependent
    beta_1 parameter, and requires an additional state variable to keep track
    of the accumulated product - something Optax currently ignores. Keras handles
    this with a different optimizer, keras.optimizer.Nadam, which does add
    the additional state variable. PyTorch also has a separate torch.optim.NAdam
    specifically for this.

…s/1412.6980).

Some specific design decisions were made that differ from Keras/Optax.
- Keras ignores the step-dependent bias correction for epsilon (google-deepmind/optax#571),
  which differs from the original paper.  We _do_ correct for the bias,
  consistent with optax/pytorch.
- Keras/pytorch support `amsgrad: bool` as an option, which changes how the variable is
  updated, keeping track of the maximum velocity encountered.  However, this
  would lead to an additional state parameter (`v_max`), and conditionally
  changes the number of slot variables.  Slot variables are particularly
  expensive in large embedding lookups (each is the size of the entire
  sharded table), and would require a different underlying primitive anyways.
  If we need the option, we can create a new optimizer.  This is consistent with optax,
  which has a separate `optax.amsgrad` optimizer.
- Optax supports a `nesterov: bool` option.  Similar to `amsgrad`, this modifies
  the update rule.  Technically the Nesterov modification also adds a step-dependent
  `beta_1` parameter, and requires an additional state variable to keep track
  of the accumulated product - something Optax currently ignores.  Keras handles
  this with a different optimizer, `keras.optimizer.Nadam`, which does add
  the additional state variable.  PyTorch also has a separate `torch.optim.NAdam`
  specifically for this.

PiperOrigin-RevId: 764333873
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant