Having just implemented a softmax() function for an online ML course, I think the python implementation here suffers from overflow if any of the elements of z get big(ish) - e.g. e^10000 is a big number! A spot of searching online suggests that subtracting max(z) from all entries in z makes it a lot more robust without changing the result e.g. https://www.tutorialexample.com/implement-softmax-function-w...
Every time I see a softmax written down I think "I should be doing physics rather than gluing layers together..." (i.e. it looks like a partition function)
5 comments
[ 3.7 ms ] story [ 23.9 ms ] thread(Relax! It's a log joke, people.)
https://physics.stackexchange.com/questions/669314/softmax-f...