Weird Error Assignment 1 question 3 - np sigmoid

Hello! I am getting the following error for my bumpy sigmoid solution: AssertionError: Not all tests were passed for sigmoid. Check your equations and avoid using global variables inside the function.

I have consulted another answer to the same question, however I dud not make the same error as that asker. Can anyone please help me figure out what I did wrong?


def sigmoid(x):
Compute the sigmoid of x

x -- A scalar or numpy array of any size

s -- sigmoid(x)

# (≈ 1 line of code)
# s = 

s = 1/(1 + np.exp(-x))


return s

Thank you!!

I think your code looks correct. Are you sure that you actually reran the sigmoid cell since the last code change you made? Just typing new code doesn’t do anything: you need to click “Shift-Enter” to execute the sigmoid cell again to recompile your new code. Just calling the function again from the test cell runs the old code until you click “Shift-Enter” on the actual sigmoid cell.

1 Like

I didn’t realize I had to hit run on the cell with the instructions (the one that says exercise 3 and shows the vectors, for anyone who is also stuck.) Thank you very much (:

This idea applies to any code cell you change: make sure to re-execute it after any change you make so that your change actually takes effect. Or you can make sure everything is consistent with what you are seeing by doing “Save”, then “Kernel → Restart and Clear Output” and then finally “Cell → Run All” or “Cell → Run All Above”.