tf.keras.optimizers.legacy.Nadam
Stay organized with collections
Save and categorize content based on your preferences.
Optimizer that implements the NAdam algorithm.
Inherits From: Nadam
, Optimizer
tf.keras.optimizers.legacy.Nadam(
learning_rate=0.001,
beta_1=0.9,
beta_2=0.999,
epsilon=1e-07,
name='Nadam',
**kwargs
)
Much like Adam is essentially RMSprop with momentum, Nadam is Adam with
Nesterov momentum.
Args |
learning_rate
|
A Tensor or a floating point value. 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 "Nadam" .
|
**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.
|
Usage Example |
>>> opt = tf.keras.optimizers.Nadam(learning_rate=0.2)
>>> var1 = tf.Variable(10.0)
>>> loss = lambda: (var1 ** 2) / 2.0
>>> step_count = opt.minimize(loss, [var1]).numpy()
>>> "{:.1f}".format(var1.numpy())
9.8
|
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.legacy.Nadam\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v2.10.0/keras/optimizers/legacy/nadam.py#L23-L25) |\n\nOptimizer that implements the NAdam algorithm.\n\nInherits From: [`Nadam`](../../../../tf/keras/optimizers/Nadam), [`Optimizer`](../../../../tf/keras/optimizers/Optimizer)\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tf.optimizers.legacy.Nadam`](https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/legacy/Nadam)\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.legacy.Nadam\\`\n\n\u003cbr /\u003e\n\n tf.keras.optimizers.legacy.Nadam(\n learning_rate=0.001,\n beta_1=0.9,\n beta_2=0.999,\n epsilon=1e-07,\n name='Nadam',\n **kwargs\n )\n\nMuch like Adam is essentially RMSprop with momentum, Nadam is Adam with\nNesterov momentum.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `learning_rate` | A Tensor or a floating point value. 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 `\"Nadam\"`. |\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\u003cbr /\u003e\n\n| Usage Example ------------- ||\n|---|---|\n| \u003cbr /\u003e \u003e\u003e\u003e opt = tf.keras.optimizers.Nadam(learning_rate=0.2) \u003e\u003e\u003e var1 = tf.Variable(10.0) \u003e\u003e\u003e loss = lambda: (var1 ** 2) / 2.0 \u003e\u003e\u003e step_count = opt.minimize(loss, [var1]).numpy() \u003e\u003e\u003e \"{:.1f}\".format(var1.numpy()) 9.8 \u003cbr /\u003e ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Reference --------- ||\n|---|---|\n| \u003cbr /\u003e - [Dozat, 2015](http://cs229.stanford.edu/proj2015/054_report.pdf). ||\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"]]