Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sigmoid Function is Incorrect #5

Open
oalieno opened this issue Dec 3, 2020 · 1 comment
Open

Sigmoid Function is Incorrect #5

oalieno opened this issue Dec 3, 2020 · 1 comment

Comments

@oalieno
Copy link
Contributor

oalieno commented Dec 3, 2020

def _sigmoid(x: float) -> float:
return 1 / (1 + np.exp(x))

should be

def _sigmoid(x: float) -> float:
    return 1 / (1 + np.exp(-x))
@oalieno
Copy link
Contributor Author

oalieno commented Dec 8, 2020

After my calculation, if we use 1 / (1 + np.exp(x)) as sigmoid function, then the derivative in the code is correct.

g = (_identity(tk is sp_tk) - _dot_sigmoid(delta, tk.v_pred)) * context.alpha()

But if we want to use the regular sigmoid function 1 / (1 + np.exp(-x)). Then we need to change the derivative to the following, which only differ by a minus sign comparing with original derivative.

 g = (_dot_sigmoid(delta, tk.v_pred) - _identity(tk is sp_tk)) * context.alpha() 

Both are correct and produce the same result. But I think using the regular sigmoid function is less confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant