Skip to content

Instantly share code, notes, and snippets.

@acl21
Created September 27, 2019 01:34
Show Gist options
  • Save acl21/f3b229d1747857235899f9e23616c7a2 to your computer and use it in GitHub Desktop.
Save acl21/f3b229d1747857235899f9e23616c7a2 to your computer and use it in GitHub Desktop.
AdaGrad
def do_adagrad():
w, b, eta = init_w, init_b, 0.1
v_w, v_b, eps = 0, 0, 1e-8
for i in range(max_epochs):
dw, db = 0, 0
for x,y in zip(X,Y):
dw += grad_w(w, b, x, y)
db += grad_b(w, b, x, y)
v_w = v_w + dw**2
v_b = v_b + db**2
w = w - (eta/np.sqrt(v_w + eps)) * dw
b = b - (eta/np.sqrt(v_b + eps)) * db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment