tf.keras.optimizers.RMSprop
Stay organized with collections
Save and categorize content based on your preferences.
Optimizer that implements the RMSprop algorithm.
Inherits From: Optimizer
tf.keras.optimizers.RMSprop(
learning_rate=0.001,
rho=0.9,
momentum=0.0,
epsilon=1e-07,
centered=False,
name='RMSprop',
**kwargs
)
The gist of RMSprop is to:
- Maintain a moving (discounted) average of the square of gradients
- Divide the gradient by the root of this average
This implementation of RMSprop uses plain momentum, not Nesterov momentum.
The centered version additionally maintains a moving average of the
gradients, and uses that average to estimate the variance.
Args |
learning_rate
|
A Tensor , floating point value, or a schedule that is a
tf.keras.optimizers.schedules.LearningRateSchedule , or a callable
that takes no arguments and returns the actual value to use. The
learning rate. Defaults to 0.001.
|
rho
|
Discounting factor for the history/coming gradient. Defaults to 0.9.
|
momentum
|
A scalar or a scalar Tensor . Defaults to 0.0.
|
epsilon
|
A small constant for numerical stability. This epsilon is
"epsilon hat" in the Kingma and Ba paper (in the formula just before
Section 2.1), not the epsilon in Algorithm 1 of the paper. Defaults to
1e-7.
|
centered
|
Boolean. If True , gradients are normalized by the estimated
variance of the gradient; if False, by the uncentered second moment.
Setting this to True may help with training, but is slightly more
expensive in terms of computation and memory. Defaults to False .
|
name
|
Optional name prefix for the operations created when applying
gradients. Defaults to "RMSprop" .
|
**kwargs
|
Keyword arguments. Allowed to be one of
"clipnorm" or "clipvalue" .
"clipnorm" (float) clips gradients by norm; "clipvalue" (float) clips
gradients by value.
|
Note that in the dense implementation of this algorithm, variables and their
corresponding accumulators (momentum, gradient moving average, square
gradient moving average) will be updated even if the gradient is zero
(i.e. accumulators will decay, momentum will be applied). The sparse
implementation (used when the gradient is an IndexedSlices
object,
typically because of tf.gather
or an embedding lookup in the forward pass)
will not update variable slices or their accumulators unless those slices
were used in the forward pass (nor is there an "eventual" correction to
account for these omitted updates). This leads to more efficient updates for
large embedding lookup tables (where most of the slices are not accessed in
a particular graph execution), but differs from the published algorithm.
Usage:
opt = tf.keras.optimizers.RMSprop(learning_rate=0.1)
var1 = tf.Variable(10.0)
loss = lambda: (var1 ** 2) / 2.0 # d(loss) / d(var1) = var1
step_count = opt.minimize(loss, [var1]).numpy()
var1.numpy()
9.683772
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 2022-10-27 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-10-27 UTC."],[],[],null,["# tf.keras.optimizers.RMSprop\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v2.8.0/keras/optimizer_v2/rmsprop.py#L26-L292) |\n\nOptimizer that implements the RMSprop algorithm.\n\nInherits From: [`Optimizer`](../../../tf/keras/optimizers/Optimizer)\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tf.optimizers.RMSprop`](https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/experimental/RMSprop)\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.RMSprop`](https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/legacy/RMSprop)\n\n\u003cbr /\u003e\n\n tf.keras.optimizers.RMSprop(\n learning_rate=0.001,\n rho=0.9,\n momentum=0.0,\n epsilon=1e-07,\n centered=False,\n name='RMSprop',\n **kwargs\n )\n\nThe gist of RMSprop is to:\n\n- Maintain a moving (discounted) average of the square of gradients\n- Divide the gradient by the root of this average\n\nThis implementation of RMSprop uses plain momentum, not Nesterov momentum.\n\nThe centered version additionally maintains a moving average of the\ngradients, and uses that average to estimate the variance.\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), or a callable that takes no arguments and returns the actual value to use. The learning rate. Defaults to 0.001. |\n| `rho` | Discounting factor for the history/coming gradient. Defaults to 0.9. |\n| `momentum` | A scalar or a scalar `Tensor`. Defaults to 0.0. |\n| `epsilon` | A small constant for numerical stability. This epsilon is \"epsilon hat\" in the Kingma and Ba paper (in the formula just before Section 2.1), not the epsilon in Algorithm 1 of the paper. Defaults to 1e-7. |\n| `centered` | Boolean. If `True`, gradients are normalized by the estimated variance of the gradient; if False, by the uncentered second moment. Setting this to `True` may help with training, but is slightly more expensive in terms of computation and memory. Defaults to `False`. |\n| `name` | Optional name prefix for the operations created when applying gradients. Defaults to `\"RMSprop\"`. |\n| `**kwargs` | Keyword arguments. Allowed to be one of `\"clipnorm\"` or `\"clipvalue\"`. `\"clipnorm\"` (float) clips gradients by norm; `\"clipvalue\"` (float) clips gradients by value. |\n\n\u003cbr /\u003e\n\nNote that in the dense implementation of this algorithm, variables and their\ncorresponding accumulators (momentum, gradient moving average, square\ngradient moving average) will be updated even if the gradient is zero\n(i.e. accumulators will decay, momentum will be applied). The sparse\nimplementation (used when the gradient is an `IndexedSlices` object,\ntypically because of [`tf.gather`](../../../tf/gather) or an embedding lookup in the forward pass)\nwill not update variable slices or their accumulators unless those slices\nwere used in the forward pass (nor is there an \"eventual\" correction to\naccount for these omitted updates). This leads to more efficient updates for\nlarge embedding lookup tables (where most of the slices are not accessed in\na particular graph execution), but differs from the published algorithm.\n\n#### Usage:\n\n opt = tf.keras.optimizers.RMSprop(learning_rate=0.1)\n var1 = tf.Variable(10.0)\n loss = lambda: (var1 ** 2) / 2.0 # d(loss) / d(var1) = var1\n step_count = opt.minimize(loss, [var1]).numpy()\n var1.numpy()\n 9.683772\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Reference --------- ||\n|---|---|\n| \u003cbr /\u003e - [Hinton, 2012](http://www.cs.toronto.edu/%7Etijmen/csc321/slides/lecture_slides_lec6.pdf) ||\n\n\u003cbr /\u003e"]]