I see nan in your cost. Please share the full error with the proper week, assignment, and exercise number.
{moderator edit - solution code removed}
kindly find the attached pic
Hello Joshua,
Thank you for your question.
Please remove the code as sharing the code on the community profile is a violation.
Thanks!
There are several problems in your code:
You have manually written out the sigmoid logic again, but it is not correct. The intent here was that you just call the sigmoid function that you wrote earlier. That’s the point of packaging that logic as a function: you only have to write the code once and then you reuse it where-ever you need it.
Your cost logic is also not correct. It will produce a 1 x m array, but you need a scalar there. Please have another look at the math formula that you are implementing for the cost and remember what that \Sigma there means.
can my lines of code be more than the expected lines of code?
I am very sorry!. Thank you very much
Yes, the grader does not care about how many lines of code you write. It does not look at your source code: it only calls your functions and checks that the return values are correct or not.
so the error is coming from my activation and cost function?
Yes, please try fixing those problems that I pointed out and then see what results you get from the tests. What we are always doing here is starting with math formulas and then we need to translate those into python and numpy code. So when things don’t work, the first step is to make sure you understand what the math formula means. Then does the code you wrote accurately reflect that.
The reason you got that NaN value in the cost is because your sigmoid logic is incorrect. The activation output values need to be between 0 and 1.
Okay. I will check my errors and comeback to you later
I have done the correction. it worked. Thank you