Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.ops.ApplyCenteredRMSProp

View Source On Gitee
class mindspore.ops.ApplyCenteredRMSProp(use_locking=False)[source]

Optimizer that implements the centered RMSProp algorithm. Please refer to the usage in source code of mindspore.nn.RMSProp.

The updating formulas of ApplyCenteredRMSProp algorithm are as follows,

gt+1=ρgt+(1ρ)Qi(w)st+1=ρst+(1ρ)(Qi(w))2mt+1=βmt+ηst+1gt+12+ϵQi(w)w=wmt+1

where w represents var, which will be updated. gt+1 represents mean_gradient, gt is the last moment of gt+1. st+1 represents mean_square, st is the last moment of st+1, mt+1 represents moment, mt is the last moment of mt+1. ρ represents decay. β is the momentum term, represents momentum. ϵ is a smoothing term to avoid division by zero, represents epsilon. η represents learning_rate. Qi(w) represents grad.

Note

The difference between ApplyCenteredRMSProp and ApplyRMSProp is that the former uses the centered RMSProp algorithm, and the centered RRMSProp algorithm uses an estimate of the centered second moment(i.e., the variance) for normalization, as opposed to regular RMSProp, which uses the (uncertained) second moment. This often helps with training, but is slightly more expensive in terms of computation and memory.

Warning

In dense implementation of this algorithm, mean_gradient, mean_square, and moment will update even if the grad is zero. But in this sparse implementation, mean_gradient, mean_square, and moment will not update in iterations during which the grad is zero.

Parameters

use_locking (bool) – Whether to enable a lock to protect the variable and accumulation tensors from being updated. Default: False .

Inputs:
  • var (Parameter) - Weights to be updated.

  • mean_gradient (Tensor) - Mean gradients, must be the same type as var.

  • mean_square (Tensor) - Mean square gradients, must be the same type as var.

  • moment (Tensor) - Delta of var, must be the same type as var.

  • grad (Tensor) - Gradient, must be the same type as var.

  • learning_rate (Union[Number, Tensor]) - Learning rate. Must be a float number or a scalar tensor with float16 or float32 data type.

  • decay (float) - Decay rate.

  • momentum (float) - Momentum.

  • epsilon (float) - Ridge term.

Outputs:

Tensor, parameters to be updated.

Raises
  • TypeError – If use_locking is not a bool.

  • TypeError – If var, mean_gradient, mean_square, moment or grad is not a Tensor.

  • TypeError – If learing_rate is neither a Number nor a Tensor.

  • TypeError – If dtype of learing_rate is neither float16 nor float32.

  • TypeError – If decay, momentum or epsilon is not a float.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, nn, ops, Parameter
>>> class Net(nn.Cell):
...     def __init__(self):
...         super(Net, self).__init__()
...         self.apply_centerd_rms_prop = ops.ApplyCenteredRMSProp()
...         self.var = Parameter(Tensor(np.ones([2, 2]).astype(np.float32)), name="var")
...
...     def construct(self, mean_grad, mean_square, moment, grad, decay, momentum, epsilon, lr):
...         out = self.apply_centerd_rms_prop(self.var, mean_grad, mean_square, moment, grad,
...                                           lr, decay, momentum, epsilon)
...         return out
...
>>> net = Net()
>>> mean_grad = Tensor(np.ones([2, 2]).astype(np.float32))
>>> mean_square = Tensor(np.ones([2, 2]).astype(np.float32))
>>> moment = Tensor(np.ones([2, 2]).astype(np.float32))
>>> grad = Tensor(np.ones([2, 2]).astype(np.float32))
>>> output = net(mean_grad, mean_square, moment, grad, 0.0, 1e-10, 0.001, 0.01)
>>> print(net.var.asnumpy())
[[0.68377227  0.68377227]
 [0.68377227  0.68377227]]