Please i don’t understand what i am supposed to do on this exercise 2. Can someone please put me through. Thank you
To refer to a function belonging to a specific package you could call it using package_name.function(). Run the code below to see an example with math.exp().
import math
from public_tests import *
GRADED FUNCTION: basic_sigmoid
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
You are supposed to write the code for this function using the functions from Math library. As you can see from the first line of this cell, there is this line:
import Math
The definition of this function begins with:
def basic_sigmoid(x):
and the code to write is within the starts and ends lines:
Your code starts here
Your code ends here
and the math function to use is: math.exp() for the exponent part of the equation sigmoid(x) = \frac{1}{1+e^{-x}}
Please read the implementation instruction carefully. It explains clearly what your function should do.
That means you have not run the cell that defines the basic_sigmoid function or perhaps you ran it, but it threw an error because the code is incomplete or incorrect. Part of what we are learning in this “optional” tutorial assignment is how to work the Jupyter Notebooks. Please make sure not to skip the video about the notebooks in Week 2, which walks you through how they work. Also there’s the “Programming FAQ” reading item. There is also a topic on the DLS FAQ Thread about the ‘name not defined’ error in general.
~/work/release/W2A1/test_utils.py in test(test_cases, target)
24 print(‘\033[92m’, success," Tests passed")
25 print(‘\033[91m’, len(test_cases) - success, " Tests failed")
—> 26 raise AssertionError(“Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))
AssertionError: Not all tests were passed for basic_sigmoid. Check your equations and avoid using global variables inside the function.
You have hard-coded the parameter to be 1, so you only get the correct answer for that particular case. The point is that you need to use the parameter x, so that your code works for any input value.
Also note that your implementation of the formula for sigmoid is not quite complete. Please compare the code you wrote to the math formula shown in the instructions.