Python error

Hi guys. I’m creating the cost function but it is returning with an error. I literally copy/pasted the code from the optional labs and its returning the same error, so I think its a Python or numpy error.

{mentor edit: code removed}

I suspect there may be an error in your sigmoid() function.

Also, be advised that the notebooks are intended to be used in the Coursea Labs environment.

If you work on the notebooks in another toolset (I see you’re using PyCharm), and plan to upload the notebook back to Coursera for grading, there is a good chance the grader will be very unhappy. This is because many tools will modify the metadata that is inside the notebook and then the grader won’t work correctly.

I debugged a bit and np.log(1-f_wb_i) is returning NaN :thinking:

I’m running the code locally, thats ok

The NaN means you’re probably trying to compute the log of a negative number, or zero, or some similar problem.

That’s why I suspect your sigmoid function (that’s what sets the f_wb_i value).

Yeah, lol. It was missing the parameters on (1 + np.exp(-z)
{mentor edit: code removed}
Thx a lot :smile:

1 Like

parentheses*

1 Like

Good that you fixed the error.

I’m going to delete your code from this thread, because posting code for the programming assignments isn’t allowed. That code is from a graded assignment.

2 Likes

Sure! I didn’t know, sorry

No problem.
Maybe review the forum Code of Conduct for future reference.

2 Likes