tf.keras.optimizers.Adamax
Stay organized with collections
Save and categorize content based on your preferences.
Optimizer that implements the Adamax algorithm.
Inherits From: Optimizer
tf.keras.optimizers.Adamax(
learning_rate=0.001,
beta_1=0.9,
beta_2=0.999,
epsilon=1e-07,
name='Adamax',
**kwargs
)
It is a variant of Adam based on the infinity norm.
Default parameters follow those provided in the paper.
Adamax is sometimes superior to adam, specially in models with embeddings.
Initialization:
m = 0 # Initialize initial 1st moment vector
v = 0 # Initialize the exponentially weighted infinity norm
t = 0 # Initialize timestep
The update rule for parameter w
with gradient g
is
described at the end of section 7.1 of the paper:
t += 1
m = beta1 * m + (1 - beta) * g
v = max(beta2 * v, abs(g))
current_lr = learning_rate / (1 - beta1 ** t)
w = w - current_lr * m / (v + epsilon)
Similarly to Adam
, the epsilon is added for numerical stability
(especially to get rid of division by zero when v_t == 0
).
In contrast to Adam
, the sparse implementation of this algorithm
(used when the gradient is an IndexedSlices object, typically because of
tf.gather
or an embedding lookup in the forward pass) only updates
variable slices and corresponding m_t
, v_t
terms when that part of
the variable was used in the forward pass. This means that the sparse
behavior is contrast to the dense behavior (similar to some momentum
implementations which ignore momentum unless a variable slice was actually
used).
Args |
learning_rate
|
A Tensor , floating point value, or a schedule that is a
tf.keras.optimizers.schedules.LearningRateSchedule . The learning rate.
|
beta_1
|
A float value or a constant float tensor. The exponential decay
rate for the 1st moment estimates.
|
beta_2
|
A float value or a constant float tensor. The exponential decay
rate for the exponentially weighted infinity norm.
|
epsilon
|
A small constant for numerical stability.
|
name
|
Optional name for the operations created when applying gradients.
Defaults to "Adamax" .
|
**kwargs
|
keyword arguments. Allowed arguments are clipvalue ,
clipnorm , global_clipnorm .
If clipvalue (float) is set, the gradient of each weight
is clipped to be no higher than this value.
If clipnorm (float) is set, the gradient of each weight
is individually clipped so that its norm is no higher than this value.
If global_clipnorm (float) is set the gradient of all weights is
clipped so that their global norm is no higher than this value.
|
Raises |
ValueError
|
in case of any invalid argument.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.keras.optimizers.Adamax\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v2.10.0/keras/optimizers/optimizer_v2/adamax.py#L26-L198) |\n\nOptimizer that implements the Adamax algorithm.\n\nInherits From: [`Optimizer`](../../../tf/keras/optimizers/Optimizer)\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tf.optimizers.Adamax`](https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/experimental/Adamax)\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n\\`tf.compat.v1.keras.optimizers.Adamax\\`\n\n\u003cbr /\u003e\n\n tf.keras.optimizers.Adamax(\n learning_rate=0.001,\n beta_1=0.9,\n beta_2=0.999,\n epsilon=1e-07,\n name='Adamax',\n **kwargs\n )\n\nIt is a variant of Adam based on the infinity norm.\nDefault parameters follow those provided in the paper.\nAdamax is sometimes superior to adam, specially in models with embeddings.\n\n#### Initialization:\n\n m = 0 # Initialize initial 1st moment vector\n v = 0 # Initialize the exponentially weighted infinity norm\n t = 0 # Initialize timestep\n\nThe update rule for parameter `w` with gradient `g` is\ndescribed at the end of section 7.1 of the paper: \n\n t += 1\n m = beta1 * m + (1 - beta) * g\n v = max(beta2 * v, abs(g))\n current_lr = learning_rate / (1 - beta1 ** t)\n w = w - current_lr * m / (v + epsilon)\n\nSimilarly to `Adam`, the epsilon is added for numerical stability\n(especially to get rid of division by zero when `v_t == 0`).\n\nIn contrast to `Adam`, the sparse implementation of this algorithm\n(used when the gradient is an IndexedSlices object, typically because of\n[`tf.gather`](../../../tf/gather) or an embedding lookup in the forward pass) only updates\nvariable slices and corresponding `m_t`, `v_t` terms when that part of\nthe variable was used in the forward pass. This means that the sparse\nbehavior is contrast to the dense behavior (similar to some momentum\nimplementations which ignore momentum unless a variable slice was actually\nused).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `learning_rate` | A `Tensor`, floating point value, or a schedule that is a [`tf.keras.optimizers.schedules.LearningRateSchedule`](../../../tf/keras/optimizers/schedules/LearningRateSchedule). The learning rate. |\n| `beta_1` | A float value or a constant float tensor. The exponential decay rate for the 1st moment estimates. |\n| `beta_2` | A float value or a constant float tensor. The exponential decay rate for the exponentially weighted infinity norm. |\n| `epsilon` | A small constant for numerical stability. |\n| `name` | Optional name for the operations created when applying gradients. Defaults to `\"Adamax\"`. |\n| `**kwargs` | keyword arguments. Allowed arguments are `clipvalue`, `clipnorm`, `global_clipnorm`. If `clipvalue` (float) is set, the gradient of each weight is clipped to be no higher than this value. If `clipnorm` (float) is set, the gradient of each weight is individually clipped so that its norm is no higher than this value. If `global_clipnorm` (float) is set the gradient of all weights is clipped so that their global norm is no higher than this value. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Reference --------- ||\n|---|---|\n| \u003cbr /\u003e - [Kingma et al., 2014](http://arxiv.org/abs/1412.6980) ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|----------------------------------|\n| `ValueError` | in case of any invalid argument. |\n\n\u003cbr /\u003e"]]