Course 1 Week2 Assignment - Excercise 5

Hey i’m not sure I’m implementing this correctly, however I’m at a loss as to how to progress - am I interpreting the following correctly? for back propagation?

# BACKWARD PROPAGATION (TO FIND GRAD)
#(≈ 2 lines of code)
# dw = ...
# db = ...
# YOUR CODE STARTS HERE
dw = (1/Y) * (np.dot(X, ((A-Y).T)))
db = (1/Y) * np.sum((A- Y), axis=1, keepdims=True)

I am getting an error with dw as the following:

AssertionError Traceback (most recent call last)
in
6
7 assert type(grads[“dw”]) == np.ndarray
----> 8 assert grads[“dw”].shape == (2, 1)
9 assert type(grads[“db”]) == np.float64
10

AssertionError:

I understand that I have the wrong shape… however from how I believe the formula described above works this should be correct? Thanks in advance.

Welcome to the forum @Tim1 !

Check the scaling coefficients for dw and db. You have 1/Y.

Also, check your optional arguments to the np.sum() function.

Good luck!

1 Like

hah! I have no idea why i missed the m = X.shape[1] -makes sense now thanks