Skip to content

Instantly share code, notes, and snippets.

@PyDataBlog
Created August 29, 2020 16:07
Show Gist options
  • Select an option

  • Save PyDataBlog/8b52151100e6614cb174dbb5b955815f to your computer and use it in GitHub Desktop.

Select an option

Save PyDataBlog/8b52151100e6614cb174dbb5b955815f to your computer and use it in GitHub Desktop.
"""
Derivative of the Sigmoid function.
"""
function sigmoid_backwards(∂A, activated_cache)
s = sigmoid(activated_cache).A
∂Z = ∂A .* s .* (1 .- s)
@assert (size(∂Z) == size(activated_cache))
return ∂Z
end
"""
Derivative of the ReLU function.
"""
function relu_backwards(∂A, activated_cache)
return ∂A .* (activated_cache .> 0)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment