Python Basics with Numpy Assignment

In the puplic_tests.py file, it’s not correct that math.exp(1) = 0.7310585786300049 nor np.exp([1, 2, 3]) = [0.73105858, 0.88079708, 0.95257413].

I’ve corrected them to be math.exp(1) = 2.718281828459045 nor np.exp([1, 2, 3]) = [ 2.71828183, 7.3890561, 20.08553692].

Hello @mahmoud_ahc,
The test is sigmoid function test, check out this video where Andrew explains the sigmoid function:

1 Like

Hi @mahmoud_ahc, in general it is a bad idea to change the expected public tests results, it may give you the wrong impression that you will pass the tests in the grader when submitting your notebook.

As indicated by @nero that function is testing the sigmoid which is not equal to math.exp as you suggest in your post. Please refer to the right formula.

Thanks for your reply, but in the notebook provided the instructions said that

Doesn’t this mean that the sigmoid function formula is implemented in two ways: math.exp() and np.exp()?

So, when applying math.exp(1), it equals to 2.718281828459045.

Please, if you have another formula, type it here.

Also, suppose that I deal with the original result written in the test file. When applying the sigmoid function of 1, it raises an error

since the real result is 2.718281828459045 as shown by the test done on the target, then it raises error in the second test as failed assertion due to difference between the actual result and written number in the test function.

!!! :man_shrugging:

@mahmoud_ahc you are mixing exponent with the whole sigmoid function. The exponent is just a part of the sigmoid function. Check out the sigmoid function formula again.

2 Likes

Exactly, in your screenshot you have the real formula:

image

2 Likes

Thanks @nero and @albertovilla! I get it. The sigmoid formula in python is written as x = 1/(1+math.exp(-x)

Thanks for your support :heart:

3 Likes