Week 2 Exercise 8 cost with wrong value

Yes, you’re right that in this case you only see the cost at 0 iterations, so it must be the case that it is just your cost logic that is incorrect. Are you sure that you included two main terms in your cost? You need to handle both the Y = 1 and the Y = 0 case, right? Please compare your cost logic to the math formula they show. Also note that there are two ways to do it: you can just use elementwise multiply followed by np.sum for each of the main terms or you can use dot product, but if you go the dot product route you need a transpose. And there are right and wrong ways to use the transpose. See this thread for examples.

1 Like