Created
May 21, 2020 21:38
-
-
Save akarsh-saxena/46363575bbc9eea388bf13e831ca6a76 to your computer and use it in GitHub Desktop.
This file contains 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
import numpy as np | |
def update_weights(params, changes, learning_rate=0.01): | |
"""Updates weights of the layers | |
Arguments | |
--------- | |
params: dict | |
Dictionary containing 'w' and 'b' | |
changes: dict | |
Dictionary containing 'dw' and 'db' | |
learning_rate: int, float | |
Learning rate for the weight update | |
Returns | |
------- | |
dict | |
Dictionary containing updated weights and biases | |
The keys for weights and bias arrays in the dict is 'w' and 'b' | |
""" | |
w = params['w'] | |
b = params['b'] | |
dw = changes['dw'] | |
db = changes['db'] | |
w -= learning_rate*dw | |
b -= learning_rate*db | |
return {'w': w, 'b': b} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment