Python syntax is not the same as math notation. If you say this in python:
s(1 - s)
What that means is that s is a function and you are calling it with the argument 1 - s. Of course if s is not actually a function, then it throws an error. If what you intended is multiplication, the way to express that in python is this:
Dear KahmilX abd Paulinpaloalto,
regarding these two lines for ex4 of assignment 1:
s=1/(1+np.exp(-x))
ds=s(1-s)
What is the purpose of the second line in ex4? The function only returns the sigmoid of x, no ds?
@anantha: the code you show has the same bug that I explained in my previous post. So your ds line will throw an error. But the point of this function is to return the derivative of sigmoid, not sigmoid itself. So the return value should be only ds. The purpose of the ds line of code is to take the sigmoid value and compute the derivative from it.
Also note that there is no need to rewrite the implementation of sigmoid within this function: you already wrote a function that computes that, so why not just call it?
Note that in all the notebooks only some of the code cells are modifiable: the cells containing the test cases that check your code are not modifiable. But you should be able to modify the functions that you are supposed to be implementing. You’ll see the sections marked “YOUR CODE HERE”.
If the test fails, the solution is not to change the test, but to figure out what is wrong with your code that causes the test to fail.