W2_Tempate Code for Validation Triggered Error

Hello, hope the community can help me solve this problem that I get stuck at. I’ve tried different ways to complete the week 2 assignment and submit the code, but it always shows the error about the line of code after each section to say: name ‘basic_sigmoid_test’ is not defined. The name within ‘’ is different for each question/answer. Since this line is in the template, I am not able to edit or delete through my keyboard. Looks like it is calling the function without any input parameter. Anyone ran into the same problem?

An example:

GRADED FUNCTION: basic_sigmoid

import math
def basic_sigmoid(x):
“”"
Compute sigmoid of x.

Arguments:
x -- A scalar

Return:
s -- sigmoid(x)
"""
# (≈ 1 line of code)
# s = 
# YOUR CODE STARTS HERE
s = 1 / (1 + math.exp(-x))
# YOUR CODE ENDS HERE
return s

print("basic_sigmoid(1) = " + str(basic_sigmoid(1)))

basic_sigmoid_test(basic_sigmoid) ---------> This is the template code triggers error

Error code:
basic_sigmoid(1) = 0.7310585786300049

NameError Traceback (most recent call last)
in
1 print("basic_sigmoid(1) = " + str(basic_sigmoid(1)))
2
----> 3 basic_sigmoid_test(basic_sigmoid)

NameError: name ‘basic_sigmoid_test’ is not defined

Hey @Jen_Y,
Welcome to the community. Mistakenly, you have deleted the code cell that contained the hidden tests for the aforementioned function. You need to get a fresh copy of your notebook and paste your solutions in it. Follow the instructions in this thread to do the same.

Cheers,
Elemento

1 Like

That’s one possibility. The other is that maybe you have not executed the “import” command in an earlier cell that imported the test functions from an external python file. Try “Cell → Run All Above” and then execute your sigmoid test again.

Thanks @paulinpaloalto Sir, I overlooked and assumed that this error was thrown by the grader, and not by running the code cell within the notebook.

Cheers,
Elemento

1 Like