Skip to content

Instantly share code, notes, and snippets.

@ksivaman
Created July 13, 2019 23:57
Show Gist options
  • Save ksivaman/3a9c281c3104ebbb052e9d754fae8ddb to your computer and use it in GitHub Desktop.
Save ksivaman/3a9c281c3104ebbb052e9d754fae8ddb to your computer and use it in GitHub Desktop.
A function to update weights and biases for a feed forward neural network.
def param_updates(params_w, params_b, gradients, lr, layers=[4, 5, 1]):
for index in range(len(layers) - 1):
#gradient descent
params_w["weight" + str(index + 1)] -= lr * gradients["d_weight" + str(index + 1)]
params_b["bias" + str(index + 1)] -= lr * gradients["d_bias" + str(index + 1)]
return params_w, params_b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment