C1-W2-A2: Forward and Backward propagation - Wrong value for cost

As Tom points out, there are a number of ways to write the code for the cost. You have two 1 x m vectors and you need the sum of the products of their corresponding elements.

Using a dot product is a fine way to do it, but you’ll need to transpose one of the vectors to get that to work. But then you need to be careful exactly how you do the transpose.

v^T dot w

gives a very different answer than

v dot w^T

Here’s a thread which discusses that point in detail and shows examples.