Week 2 assignment ex 5 compute cost

Hi,
I am struggling with getting exercise 5 right of the programming assignment. My problem comes from the cost function J that does not match the one in the test:
AssertionError: Wrong values for cost. 10.604635958182634 != 5.80154531 (at leat the dimension is right)

I have computed the cost in a vectorized way, that was not covered in the previous courses (see discussion here). Do we have to write a for loop to compute the cost? In the comment, it says it should only take 2 lines of codes, so I figured it should be vectorized, but my vectorization is wrong.

Can someone confirm it is meant to be written as a loop? Where my mistake could come from?

Thanks a lot!

Nevermind, I found my mistake. I have to keep in mind that the dimension of np.dot(Y.T,log(A)) is (1,1) …

Hi @petril48 , good to see you found the solution!