C2_W3_Assignment: matmul error in forward_propagation()

I keep getting this error even though there is no mismatch in W2 and X shape.

The error:

Cell In [112], line 26, in forward_propagation(X, parameters)
     24 Z1 = np.matmul(W1, X) + b1
     25 A1 = sigmoid(Z1)
---> 26 Z2 = np.matmul(W2, X) + b2
     27 A2 = sigmoid(Z2)
     28 ### END CODE HERE ###

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 3)

Shape of W2 and X:

print('W2:', np.shape(parameters['W2']))
print('X:', np.shape(X))

# output
W2: (1, 2)
X: (2, 2000)

Help me please, I have been stuck in this assignment for a week.

image

That’s not the correct variable to use.

1 Like