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

Softmax derivative is wrong #11

Open
giladfrid009 opened this issue May 11, 2020 · 0 comments · Fixed by #12
Open

Softmax derivative is wrong #11

giladfrid009 opened this issue May 11, 2020 · 0 comments · Fixed by #12

Comments

@giladfrid009
Copy link

The softmax derivative implemented is wrong, since each input of softmax layer affects other inputs of the same layer. Therefore, when calculating the derivative of certain softmax input, other inputs have to be taken into account also.
A good explanation and clarification on the topic could be found here: (check Viviek's answer) https://stats.stackexchange.com/questions/235528/backpropagation-with-softmax-cross-entropy?newreg=2a0e1acc95e345d6b1d0197d64fa1b25

Xi - input value of index i
S(Xi) - softmax of Xi

Softmax derivative when index input(i) == index output(j): S(Xi) * (1-S(Xj))

Softmax derivative when index input (i) != index output (j): -S(Xi) * S(Xj)

You can check my custom softmax layer implementation for more details.

@nirex0 nirex0 mentioned this issue May 12, 2020
@nirex0 nirex0 linked a pull request May 12, 2020 that will close this issue
nirex0 added a commit that referenced this issue May 12, 2020
@nirex0 nirex0 reopened this May 24, 2020
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

Successfully merging a pull request may close this issue.

2 participants