4.3 - Forward and Backward propagation

Hi,

I am confused as to how we are multiplying the following: (in the test section)
np.dot(w.T,X)

X is (1,3) and w is (1,2)

How is this multiplication happening?

You don’t really say, but I’m guessing you are talking about the propagate routine in the Week 2 Logistic Regression assignment. Here is the test cell:

w =  np.array([[1.], [2]])
b = 1.5
X = np.array([[1., -2., -1.], [3., 0.5, -3.2]])
Y = np.array([[1, 1, 0]])
grads, cost = propagate(w, b, X, Y)

assert type(grads["dw"]) == np.ndarray
assert grads["dw"].shape == (2, 1)
assert type(grads["db"]) == np.float64


print ("dw = " + str(grads["dw"]))
print ("db = " + str(grads["db"]))
print ("cost = " + str(cost))

propagate_test(propagate)

It looks like you are reading it incorrectly. The value of X shown there is 2 x 3. Notice that there are two levels of brackets there: the inner two sets of brackets show you the two rows separated by commas.

And w is 2 x 1, so w^T is 1 x 2 and that matrix multiplication works fine, giving you a 1 x 3 result.