a more efficient (log)sofmax
Open
@bob-carpenter is already working on this.
Since Aug 10, 2022.
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
Description
I've just recently read https://academic.oup.com/imajna/article/41/4/2311/5893596?login=false
which shows that for log-softmax implemented as
a <- max(x); log(exp(x - a)/sum(exp(x-a)))
is more accurate than this version (which as far as I understand the hpp files is the one that Stan uses)
x - matrixStats::logSumExp(x)
(Sorry for the R code, but the point is the same).
I just thought it was worth to point this out. If there are good reasons for the way softmax is implemented, please just close and ignore, otherwise it might be useful...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.