class paddle.fluid.optimizer.DecayedAdagradOptimizer(learning_rate, decay=0.95, epsilon=1e-06, regularization=None, name=None)[source]

The Decayed Adagrad optimizer can be seen as an Adagrad algorithm that introduces the decay rate to solve the problem of a sharp drop in the learning rate during model training when using the AdagradOptimizer.

The parameter param_out update rule with gradient grad:

\begin{align}\begin{aligned}moment\_out & = decay * moment + (1 - decay) * grad * grad\\param\_out & = param - \frac{learning\_rate * grad}{\sqrt{moment\_out} + \epsilon}\end{aligned}\end{align}

The original paper does not have an epsilon attribute. It is added here for numerical stability to avoid the division by zero error.

Parameters
• learning_rate (float|Variable) – The learning rate used to update Parameter. It can be a float value or a Variable with a float type.

• decay (float, optional) – The decay rate. The default value is 0.95.

• epsilon (float, optional) – A small float value for numerical stability. The default value is 1e-06.

• regularization (WeightDecayRegularizer, optional) – A Regularizer, such as L2DecayRegularizer. The default value is None.

• name (str, optional) – Normally there is no need for user to set this property. For more information, please refer to Name. The default value is None.

Notes:

Examples

import paddle.fluid as fluid

x = fluid.data( name='x', shape=[None, 10], dtype='float32' )
trans = fluid.layers.fc( x, 100 )
cost = fluid.layers.reduce_mean( trans )
optimizer.minimize(cost)

minimize(loss, startup_program=None, parameter_list=None, no_grad_set=None, grad_clip=None)

Add operations to minimize loss by updating parameter_list.

Parameters
• loss (Variable) – A Variable containing the value to minimize.

• startup_program (Program, optional) – Program for initializing parameters in parameter_list. The default value is None, at this time default_startup_program will be used.

• parameter_list (list, optional) – List of Variable names to update to minimize loss. The default value is None, at this time all parameters will be updated.

• no_grad_set (set, optional) – Set of Variable objects that don’t need to be updated. The default value is None.

• grad_clip (GradClipBase, optional) – Gradient clipping strategy, static graph mode does not need to use this argument. Currently, this argument only supports gradient clipping in dygraph mode. In the future, this argument my be adjusted. The default value is None.

Returns

tuple (optimize_ops, params_grads), A list of operators appended by minimize and a list of (param, grad) variable pairs, param is Parameter, grad is the gradient value corresponding to the parameter.

Return type

tuple

Examples

Please refer to the example of current Optimizer.

set_dict(state_dict)

Load optimizer state dict. For Adam opimizer, contains beta1, beta2, momentum etc. If LearningRateDecay have been used, global_step will be changed.

Parameters

state_dict (dict) – Dict contains all the Variable needed by optimizer

Returns

None

Examples

with fluid.dygraph.guard():
emb = fluid.dygraph.Embedding( "emb", [10, 10])

state_dict = emb.state_dict()


state_dict()
import paddle.fluid as fluid