Skip to content

Instantly share code, notes, and snippets.

@PyDataBlog
Last active October 11, 2020 11:07
Show Gist options
  • Select an option

  • Save PyDataBlog/815b9d217e8888ec919d12f8d70d77a5 to your computer and use it in GitHub Desktop.

Select an option

Save PyDataBlog/815b9d217e8888ec919d12f8d70d77a5 to your computer and use it in GitHub Desktop.
"""
Update the paramaters of the model using the gradients (∇)
and the learning rate (η).
"""
function update_model_weights(parameters, ∇, η)
L = Int(length(parameters) / 2)
# Update the parameters (weights and biases) for all the layers
for l = 0: (L-1)
parameters[string("W_", (l + 1))] -= η .* ∇[string("∂W_", (l + 1))]
parameters[string("b_", (l + 1))] -= η .* ∇[string("∂b_", (l + 1))]
end
return parameters
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment