Adagrad adapts the learning rate for each parameter by accumulating squared gradients. This works well when parameters have different update frequencies, but its accumulator only grows over time.
As the accumulated squared gradients become larger, the effective learning rate keeps getting smaller. Eventually, updates can become extremely small even when further learning would still be useful.
Adadelta addresses this by replacing the ever-growing sum with exponentially decaying averages. It keeps track of two quantities:
The update used in this exercise is:
square_avgnew=ρ⋅square_avg+(1−ρ)⋅grad2 delta=square_avgnew+epsacc_delta+eps⋅grad paramnew=param−lr⋅delta acc_deltanew=ρ⋅acc_delta+(1−ρ)⋅delta2Both square_avg and acc_delta start at zeros.
Implement:
adadelta_step(
param,
grad,
square_avg,
acc_delta,
lr,
rho,
eps,
)
The function returns:
(new_param, new_square_avg, new_acc_delta)
The signature is provided in the editor.
The function should first update the moving average of squared gradients. That value determines the scale of the current update.
After computing the update delta, use it to update both the parameter and the moving average of squared updates.
param, grad, square_avg, and acc_delta must have the same shape. A mismatch raises ValueError.lr must be greater than 0. Otherwise, raise ValueError.rho must be in [0, 1). Otherwise, raise ValueError.eps must be greater than 0. Otherwise, raise ValueError.square_avg starts at zeros.acc_delta starts at zeros.Compute square_avg_new first. It is an exponentially weighted average of the squared gradient.
Compute delta using both the previous acc_delta and the newly computed square_avg_new.
After computing delta, use it to update both param and acc_delta.
No results yet
Run your code to check it against the examples, or submit to run every test.