This is Course 1, so we don’t know about TensorFlow yet, only numpy. You can use dot product, but you have to get the transpose in the right place. As you saw, transposing the first argument is wrong. Try transposing the second one, then you have 1 x m dotted with m x 1, which gives a 1x 1 output, right?
Then you don’t need the sum. That’s why dot product is better here: it does both multiply and sum in one operation, although np.multiply followed by np.sum gives the same answer.
Note that np.matmul is equivalent to np.dot: both are “dot product” style matrix multiply. Prof Ng always uses np.dot for some reason, but they are interchangeable for our purposes here. Whereas np.multiply and * both do “elementwise” multiply.