Hi, everyone, I got stuck in public test section, I wrote the cost function using loop, and it showed the expected output for the previous 2 test, but failed to the public test, may I know what’s the problem about this? Thank you for your help!

{code removed by mentor}

Hi @OUYANG_YUCHEN,

Check out the formula that r(i, j) multiplies to the whole error term, and compare that to your work.

Cheers,

Raymond

PS: I removed your code since we can’t share it here.

Hi, thx for your replying, I thought there might be no wrong with my implementation as I saw one peer’s post in this community, although the way of coding differs, we got the same wrong answer like around 14 (expected one is 13) , is it probably with the rounding issues?

I made my previous comment because you hadn’t implemented the equation as required. In the implementation you shared, even if `R[i, j] = 0`

, the corresponding error term won’t be zeroed out but equal to `Y[i, j]**2`

. If you read your code again, can you disagree with that?

We have tested the exercise and we know that a correct implementation can pass the tests.

Raymond

PS: it is difficult to discuss from your point of view because of lack of reference. For example,

- what is that peer’s post? Link?
- what answer did you get (your screenshot excluded that)?
- How many decimal places are of concern when you talked about rounding issue?
- Also, that didn’t justify that you could change the equation from the required form to how you have implemented it.

Hello mentor, and I checked my code again carefully and yeah, as you said, it was my mistake . I was careless and didn’t find this error at first. I found the wrong part and changed that line like this:

the error fixed. Thank you mentor for your kind help!

PS: This is the reference of the wrong answer link, who got the same wrong testing value as mine.

Hi @OUYANG_YUCHEN,

No problem

If we knew there was a mistake, we wouldn’t have asked the question. if we asked the question, we didn’t know there was a mistake. Sometimes our challenge is to draw a learner’s attention to the mistake that the learner had overlooked. I asked a few aggressive questions in the hope that you would examine it again. Thanks for doing it

Cheers,

Raymond