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

Notes: This API does not support sparse parameter optimization.

The update is done as follows:

\begin{align}\begin{aligned}E(g_t^2) &= \rho * E(g_{t-1}^2) + (1-\rho) * g^2\\learning\_rate &= \sqrt{ ( E(dx_{t-1}^2) + \epsilon ) / ( E(g_t^2) + \epsilon ) }\\E(dx_t^2) &= \rho * E(dx_{t-1}^2) + (1-\rho) * (-g*learning\_rate)^2\end{aligned}\end{align}
Parameters
• learning_rate (float|Variable) – global learning rate.

• epsilon (float) – a small float number for numeric stability. Default 1.0e-6.

• rho (float) – a floating point value indicating the decay rate. Default 0.95.

• regularization (WeightDecayRegularizer, optional) – A Regularizer, such as fluid.regularizer.L2DecayRegularizer. Default None, meaning that there is no regularization.

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

Examples

import paddle.fluid as fluid

image = fluid.data(name='image', shape=[None, 28], dtype='float32')
fc = fluid.layers.fc(image, size=10)
cost = fluid.layers.reduce_mean(fc)
learning_rate=0.0003, epsilon=1.0e-6, rho=0.95)

# optimizer_ops is a list of optimizer operators to update parameters
# params_grads is a list of (param, param_grad), where param is each

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()

Get state dict information from optimizer. It contain all the variable used by optimizer. For Adam opimizer, contains beta1, beta2, momentum etc. If LearningRateDecay have been used, global_step will be include in state dict. If the optimzier never be called(minimize function), the state_dict is empty.

Args: None :returns: dict contains all the variablel used by optimizer :rtype: state_dict(dict)

Examples

import paddle.fluid as fluid