iamtrask.github.io icon indicating copy to clipboard operation
iamtrask.github.io copied to clipboard

Incorrect derivative of sigmoid function

Open taylorkm opened this issue 7 years ago • 0 comments

The python code available via https://iamtrask.github.io/2015/07/12/basic-python-network/ has a sigmoid function written as

# sigmoid function
def nonlin(x,deriv=False):
    if(deriv==True):
        return x*(1-x)
    return 1/(1+np.exp(-x))

and it should be something like

# sigmoid function
def nonlin(x,deriv=False):
    if deriv:
        tmp = nonlin(x)
        return tmp*(1-tmp)
    return 1/(1+np.exp(-x))

taylorkm avatar Jul 18 '18 04:07 taylorkm