10.9. Adadelta

Adadelta is yet another variant of AdaGrad. The main difference lies in the fact that it decreases the amount by which the learning rate is adaptive to coordinates. Moreover, traditionally it referred to as not having a learning rate since it uses the amount of change itself as calibration for future change. The algorithm was proposed in [Zeiler, 2012]. It is fairly straightforward, given the discussion of previous algorithms so far.

10.9.1. The Algorithm

In a nutshell Adadelta uses two state variables, \(\mathbf{s}_t\) to store a leaky average of the second moment of the gradient and \(\Delta\mathbf{x}_t\) to store a leaky average of the second moment of the change of parameters in the model itself. Note that we use the original notation and naming of the authors for compatibility with other publications and implementations (there’s no other real reason why one should use different Greek variables to indicate a parameter serving the same purpose in momentum, Adagrad, RMSProp and Adadelta). The parameter du jour is \(\rho\). We obtain the following leaky updates:

(10.9.1)\[\begin{split}\begin{aligned} \mathbf{s}_t & = \rho \mathbf{s}_{t-1} + (1 - \rho) \mathbf{g}_t^2 \\ \mathbf{g}_t' & = \sqrt{\frac{\Delta\mathbf{x}_{t-1} + \epsilon}{\mathbf{s}_t + \epsilon}} \odot \mathbf{g}_t \\ \mathbf{x}_t & = \mathbf{x}_{t-1} - \mathbf{g}_t' \\ \Delta \mathbf{x}_t & = \rho \Delta\mathbf{x}_{t-1} + (1 - \rho) \mathbf{x}_t^2 \end{aligned}\end{split}\]

The difference to before is that we perform updates with the rescaled gradient \(\mathbf{g}_t'\) which is computed by taking the ratio between the average squared rate of change and the average second moment of the gradient. The use of \(\mathbf{g}_t'\) is purely for notational convenience. In practice we can implement this algorithm without the need to use additional temporary space for \(\mathbf{g}_t'\). As before \(\eta\) is a parameter ensuring nontrivial numerical results, i.e. avoiding zero step size or infinite variance. Typically we set this to \(\eta = 10^{-5}\).

10.9.2. Implementation

Adadelta needs to maintain two state variables for each variable, \(\mathbf{s}_t\) and \(\Delta\mathbf{x}_t\). This yields the following implementation.

%matplotlib inline
import d2l
from mxnet import np, npx
npx.set_np()

def init_adadelta_states(feature_dim):
    s_w, s_b = np.zeros((feature_dim, 1)), np.zeros(1)
    delta_w, delta_b = np.zeros((feature_dim, 1)), np.zeros(1)
    return ((s_w, delta_w), (s_b, delta_b))

def adadelta(params, states, hyperparams):
    rho, eps = hyperparams['rho'], 1e-5
    for p, (s, delta) in zip(params, states):
        # in-place updates via [:]
        s[:] = rho * s + (1 - rho) * np.square(p.grad)
        g = (np.sqrt(delta + eps) / np.sqrt(s + eps)) * p.grad
        p[:] -= g
        delta[:] = rho * delta + (1 - rho) * g * g

Choosing \(\rho = 0.9\) amounts to a half-life time of 10 for each parameter update. This tends to work quite well. We get the following behavior.

data_iter, feature_dim = d2l.get_data_ch10(batch_size=10)
d2l.train_ch10(adadelta, init_adadelta_states(feature_dim),
               {'rho': 0.9}, data_iter, feature_dim);
loss: 0.244, 0.084 sec/epoch
../_images/output_adadelta_379e43_3_1.svg

For a concise implementation we simply use the adadelta algorithm from the Trainer class. This yields the following one-liner for a much more compact invocation.

d2l.train_gluon_ch10('adadelta', {'rho': 0.9}, data_iter)
loss: 0.247, 0.089 sec/epoch
../_images/output_adadelta_379e43_5_1.svg

10.9.3. Summary

  • Adadelta has no learning rate parameter. Instead, it uses the rate of change in the parameters itself to adapt the learning rate.

  • Adadelta requires two state variables to store the second moments of gradient and the change in parameters.

  • Adadelta uses leaky averages to keep a running estimate of the appropriate statistics.

10.9.4. Exercises

  1. Adjust the value of \(\rho\). What happens?

  2. Show how to implement the algorithm without the use of \(\mathbf{g}_t'\). Why might this be a good idea?

  3. Is Adadelta really learning rate free? Could you find optimization problems that break Adadelta?

  4. Compare Adadelta to Adagrad and RMS prop to discuss their convergence behavior.

10.9.5. Discussions

image0