class brainpy.optimizers.Adagrad(lr, train_vars=None, epsilon=1e-06, name=None)[source]#

Optimizer that implements the Adagrad algorithm.

Adagrad 3 is an optimizer with parameter-specific learning rates, which are adapted relative to how frequently a parameter gets updated during training. The more updates a parameter receives, the smaller the updates.

\[\theta_{t+1} = \theta_{t} - \dfrac{\eta}{\sqrt{G_{t} + \epsilon}} \odot g_{t}\]

where \(G(t)\) contains the sum of the squares of the past gradients

One of Adagrad’s main benefits is that it eliminates the need to manually tune the learning rate. Most implementations use a default value of 0.01 and leave it at that. Adagrad’s main weakness is its accumulation of the squared gradients in the denominator: Since every added term is positive, the accumulated sum keeps growing during training. This in turn causes the learning rate to shrink and eventually become infinitesimally small, at which point the algorithm is no longer able to acquire additional knowledge.


lr (float, Scheduler) – learning rate.



Duchi, J., Hazan, E., & Singer, Y. (2011). Adaptive Subgradient Methods for Online Learning and Stochastic Optimization. Journal of Machine Learning Research, 12, 2121–2159. Retrieved from

__init__(lr, train_vars=None, epsilon=1e-06, name=None)[source]#


__init__(lr[, train_vars, epsilon, name])


load_states(filename[, verbose])

Load the model states.

nodes([method, level, include_self])

Collect all children nodes.

register_implicit_nodes(*nodes, **named_nodes)

register_implicit_vars(*variables, ...)


save_states(filename[, variables])

Save the model states.

train_vars([method, level, include_self])

The shortcut for retrieving all trainable variables.

unique_name([name, type_])

Get the unique name for this object.


vars([method, level, include_self])

Collect all variables in this node and the children nodes.



Name of the model.