Last active
May 15, 2019 19:04
-
-
Save acl21/686a9bc9ed34455c6fe618adb912e439 to your computer and use it in GitHub Desktop.
Momentum-Based Gradient Descent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_momentum_gradient_descent(): | |
w, b, eta = init_w, init_b, 1.0 | |
prev_v_w, prev_v_b, gamma = 0, 0, 0.9 | |
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 = gamma * prev_v_w + eta*dw | |
v_b = gamma * prev_v_b + eta*db | |
w = w - v_w | |
b = b - v-b | |
prev_v_w = v_w | |
prev_v_b = v_b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment