Skip to content

Instantly share code, notes, and snippets.

@marcopeix
Created February 26, 2019 18:08
Show Gist options
  • Save marcopeix/740a7a3eb31876177dc5eba5f62e1ac6 to your computer and use it in GitHub Desktop.
Save marcopeix/740a7a3eb31876177dc5eba5f62e1ac6 to your computer and use it in GitHub Desktop.
def linear_backward(dZ, cache):
A_prev, W, b = cache
m = A_prev.shape[1]
dW = (1 / m) * np.dot(dZ, cache[0].T)
db = (1/m) * np.sum(dZ, axis=1, keepdims=True)
dA_prev = np.dot(cache[1].T, dZ)
assert (dA_prev.shape == A_prev.shape)
assert (dW.shape == W.shape)
assert (db.shape == b.shape)
return dA_prev, dW, db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment