DLS Course 1 Week 2 # Python Basics with Numpy All test passed but graded only 88/100

Hi Mentor,

In the # Python Basics with Numpy of DLS Course 1 week 2
I got “All tests passed.” but after submitting and even tried Kernel > restart and clear output , I got only 88/100 point due to the error below
----> 2 print("sigmoid(t_x) = " + str(sigmoid(t_x)))
NameError: name ‘sigmoid’ is not defined

Again, I double checked many times to make sure "“All tests passed.” for the graded function above.
Could you please help me to find out what wrong it is.
Thank you.

Hi @LienNT,

The NameError suggests to us that the sigmoid function is not part of your namespace when it is being called. This could simply mean that the cell where you helped to complete the sigmoid(...) function has not been executed prior to it’s call later on in the notebook.

Please be sure that all of the cells have been run. If that works, great! If not, could you identify for me which cell in the notebook is throwing the NameError exception? Thanks!

1 Like

Hi @Kenb,

Thank you for your reply.

Yeah, I think so.
I double checked to make sure all of the cells have been run. I got “All tests passed.” on the notebook but the error doesn’t disappear.
In [25] is the cell where the NameError exception is throwed. It is provided code, not graded function code.

t_x = np.array([1, 2, 3])
print("sigmoid(t_x) = " + str(sigmoid(t_x)))
sigmoid_test(sigmoid)

In [24] is my grade function

# GRADED FUNCTION: sigmoid
def sigmoid(x):
    #my code 
    return s

Could you tell me why.
Thank you.

The cell numbers actually don’t (e.g. [25], [25]) help because those will change each time they are run. So it looks like that you are encountering the error by executing the cell directly below your sigmoid function? Just to be clear, this is Exercise3 of “Logistic_ Regression_with_a_Neural_Network_Mindset” where the problem occurs, correct?

Can you verify that you have not accidentally changed the name of the function in its signature? It should be def sigmoid(z): And when you run that cell, there are no exceptions, right?

1 Like

Hi @kenb

Sorry for replying late.
It isn’t Exercise3 of “Logistic_ Regression_with_a_Neural_Network_Mindset”.
It is Python_Basics_with_Numpy, Exercise 3 - sigmoid.

There is no exceptions at all.

By the way, different with other exercises in the “Python_Basics_with_Numpy” only this Exercise 3 has test function where the above error occurs staying above the #graded function. I think this is the reason.
Could you please check.

I have the same problem. All the exercise pass the test. But still only 88 points. I even commented out the cell with the error which was put there on purpose.

It is hard to write test cases that catch everything. One classic type of bug that the tests don’t catch is referencing global variables instead of the parameters passed to your functions. If you happen to reference the correct globals in the notebook, you pass there, but then crash and burn when you run in the grader context.

Thanks! Just wanten to take the notebook and der if it was possible to use it with mine own dataset. That is for me the best way to learn. But I can imagine it.
Kind regards,
Aart Spilt