-
-
Save brainprint/bd5bc8cff319b74ff5545e513b16de4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## from http://tr.im/hH5A | |
logsumexp <- function (x) { | |
y = max(x) | |
y + log(sum(exp(x - y))) | |
} | |
softmax <- function (x) { | |
exp(x - logsumexp(x)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment