In the programming assignment we define the compute_cost(A2, Y) function. I define it as
compute_cost(A2, Y) :
cost = - np.squeeze(np.dot(np.log(A2), Y.T))
return cost
The test on this fails like this:
cost = 0.6926858869721941
Error: Wrong output
1 Tests passed
1 Tests failed
Expected output
cost = 0.6930587610394646
The rest of the assignment works perfectly. I got 88/100 because of this. Could it a problem with the expected output?
Thanks,
AM
Hi @mradassaad , welcome to the Discourse community. I am not sure where the Y.T is coming from, but first of all make sure to implement the full cost function. The instructions give you part of the solution
logprobs = np.multiply(np.log(A2),Y)
cost = - np.sum(logprobs)
But there is an additional part to be added.
Hope this helps.
1 Like
Hi @sjfischer. Thank you for your answer!
Are you referring to the part where we squeeze the array to take away all unnecessary dimensions?
cost = float(np.squeeze(cost))
I have already done so, yet I still get the test as failed… Not sure what is happening.
Assaad
Hi @mradassaad , I am referring to logprobs, which actually has two parts. One part is mentioned in the instructions, but there is a second part to be added. It might be that the test fails because of that.
1 Like
Got it! I fixed the issue. Thank you so much @sjfischer .
1 Like
@mradassaad Great to hear it is solved!