# Week 2 - Ex 5 - Problem with cost function

Hi every one …

Can somebody tell me why my implementation won’t pass the tests? I’m pretty sure it’s correct

{moderator edit - solution code removed}

Welcome to the community.

First of all, please do not paste your code in here. It is not recommended.

Both 2 lines that you added are incorrect. Looks like you just copied the instruction, but that is only part of answers, of course. Instructions do never provide answers.

There are two key points.
What you need to implement is this equation.

J = - \frac{1}{m} \sum\limits_{i = 1}^{m} \large{(} \small y^{(i)}\log\left(a^{[2] (i)}\right) + (1-y^{(i)})\log\left(1- a^{[2] (i)}\right) \large{)} \small\tag{13}

And, what you implemented is just part of it.

- \sum\limits_{i=1}^{m} y^{(i)}\log(a^{[2](i)})

So, you need to implement the rest, and also consider \frac{1}{m}.

thanks for yout answer. I ended up with this equation, and I worked perfectly

{moderator edit - solution code removed}

Ok… thanks. I see the phrase “one part”… I’ll give it a try again

Pd. Why is not recommended to paste my code here?

Bes regards

Pd. Why is not recommended to paste my code here?

Actually, it is strictly prohibited. This is an open community. So, anyone can take a look, and may pickup code that someone wrote for grader assignments.

Ok… thanks. I see the phrase “one part”… I’ll give it a try again

You already implemented the rest in updated equation.

1 Like

then … How can I show the state of my code so that I can be advised or corrected??

Best regards

Usually, we try to diagnose from the Traceback. If there is no clue, then, mentors may ask you to DM a notebook file privately.

For the community rule, please refer this. Discourse Guidelines