<s>
The	O
softmax	B-Algorithm
function	I-Algorithm
,	O
also	O
known	O
as	O
softargmax	B-Algorithm
or	O
normalized	B-Algorithm
exponential	I-Algorithm
function	O
,	O
converts	O
a	O
vector	O
of	O
real	O
numbers	O
into	O
a	O
probability	O
distribution	O
of	O
possible	O
outcomes	O
.	O
</s>
<s>
The	O
softmax	B-Algorithm
function	I-Algorithm
is	O
often	O
used	O
as	O
the	O
last	O
activation	B-Algorithm
function	I-Algorithm
of	O
a	O
neural	B-Architecture
network	I-Architecture
to	O
normalize	O
the	O
output	O
of	O
a	O
network	O
to	O
a	O
probability	O
distribution	O
over	O
predicted	O
output	O
classes	O
,	O
based	O
on	O
Luce	O
's	O
choice	O
axiom	O
.	O
</s>
<s>
The	O
softmax	B-Algorithm
function	I-Algorithm
takes	O
as	O
input	O
a	O
vector	O
of	O
real	O
numbers	O
,	O
and	O
normalizes	O
it	O
into	O
a	O
probability	O
distribution	O
consisting	O
of	O
probabilities	O
proportional	O
to	O
the	O
exponentials	O
of	O
the	O
input	O
numbers	O
.	O
</s>
<s>
For	O
this	O
reason	O
,	O
some	O
prefer	O
the	O
more	O
accurate	O
term	O
"	O
softargmax	B-Algorithm
"	O
,	O
but	O
the	O
term	O
"	O
softmax	O
"	O
is	O
conventional	O
in	O
machine	O
learning	O
.	O
</s>
<s>
This	O
section	O
uses	O
the	O
term	O
"	O
softargmax	B-Algorithm
"	O
to	O
emphasize	O
this	O
interpretation	O
.	O
</s>
<s>
With	O
the	O
last	O
expression	O
given	O
in	O
the	O
introduction	O
,	O
softargmax	B-Algorithm
is	O
now	O
a	O
smooth	O
approximation	O
of	O
arg	O
max	O
:	O
as	O
,	O
softargmax	B-Algorithm
converges	O
to	O
arg	O
max	O
.	O
</s>
<s>
There	O
are	O
various	O
notions	O
of	O
convergence	O
of	O
a	O
function	O
;	O
softargmax	B-Algorithm
converges	O
to	O
arg	O
max	O
pointwise	B-Algorithm
,	O
meaning	O
for	O
each	O
fixed	O
input	O
as	O
,	O
However	O
,	O
softargmax	B-Algorithm
does	O
not	O
converge	B-Algorithm
uniformly	I-Algorithm
to	O
arg	O
max	O
,	O
meaning	O
intuitively	O
that	O
different	O
points	O
converge	O
at	O
different	O
rates	O
,	O
and	O
may	O
converge	O
arbitrarily	O
slowly	O
.	O
</s>
<s>
In	O
fact	O
,	O
softargmax	B-Algorithm
is	O
continuous	O
,	O
but	O
arg	O
max	O
is	O
not	O
continuous	O
at	O
the	O
singular	O
set	O
where	O
two	O
coordinates	O
are	O
equal	O
,	O
while	O
the	O
uniform	B-Algorithm
limit	I-Algorithm
of	O
continuous	O
functions	O
is	O
continuous	O
.	O
</s>
<s>
The	O
reason	O
it	O
fails	O
to	O
converge	B-Algorithm
uniformly	I-Algorithm
is	O
that	O
for	O
inputs	O
where	O
two	O
coordinates	O
are	O
almost	O
equal	O
(	O
and	O
one	O
is	O
the	O
maximum	O
)	O
,	O
the	O
arg	O
max	O
is	O
the	O
index	O
of	O
one	O
or	O
the	O
other	O
,	O
so	O
a	O
small	O
change	O
in	O
input	O
yields	O
a	O
large	O
change	O
in	O
output	O
.	O
</s>
<s>
However	O
,	O
softargmax	B-Algorithm
does	O
converge	B-Algorithm
compactly	I-Algorithm
on	O
the	O
non-singular	O
set	O
.	O
</s>
<s>
Conversely	O
,	O
as	O
,	O
softargmax	B-Algorithm
converges	O
to	O
arg	O
min	O
in	O
the	O
same	O
way	O
,	O
where	O
here	O
the	O
singular	O
set	O
is	O
points	O
with	O
two	O
arg	O
min	O
values	O
.	O
</s>
<s>
In	O
probability	O
theory	O
,	O
the	O
output	O
of	O
the	O
softargmax	B-Algorithm
function	O
can	O
be	O
used	O
to	O
represent	O
a	O
categorical	O
distribution	O
–	O
that	O
is	O
,	O
a	O
probability	O
distribution	O
over	O
different	O
possible	O
outcomes	O
.	O
</s>
<s>
In	O
statistical	O
mechanics	O
,	O
the	O
softargmax	B-Algorithm
function	O
is	O
known	O
as	O
the	O
Boltzmann	O
distribution	O
(	O
or	O
Gibbs	O
distribution	O
)	O
:	O
the	O
index	O
set	O
are	O
the	O
microstates	O
of	O
the	O
system	O
;	O
the	O
inputs	O
are	O
the	O
energies	O
of	O
that	O
state	O
;	O
the	O
denominator	O
is	O
known	O
as	O
the	O
partition	O
function	O
,	O
often	O
denoted	O
by	O
;	O
and	O
the	O
factor	O
is	O
called	O
the	O
coldness	O
(	O
or	O
thermodynamic	O
beta	O
,	O
or	O
inverse	O
temperature	O
)	O
.	O
</s>
<s>
The	O
softmax	B-Algorithm
function	I-Algorithm
is	O
used	O
in	O
various	O
multiclass	B-General_Concept
classification	I-General_Concept
methods	O
,	O
such	O
as	O
multinomial	O
logistic	O
regression	O
(	O
also	O
known	O
as	O
softmax	O
regression	O
)	O
,	O
multiclass	O
linear	B-General_Concept
discriminant	I-General_Concept
analysis	I-General_Concept
,	O
naive	B-General_Concept
Bayes	I-General_Concept
classifiers	I-General_Concept
,	O
and	O
artificial	B-Architecture
neural	I-Architecture
networks	I-Architecture
.	O
</s>
<s>
Specifically	O
,	O
in	O
multinomial	O
logistic	O
regression	O
and	O
linear	B-General_Concept
discriminant	I-General_Concept
analysis	I-General_Concept
,	O
the	O
input	O
to	O
the	O
function	O
is	O
the	O
result	O
of	O
distinct	O
linear	O
functions	O
,	O
and	O
the	O
predicted	O
probability	O
for	O
the	O
th	O
class	O
given	O
a	O
sample	O
vector	O
and	O
a	O
weighting	O
vector	O
is	O
:	O
</s>
<s>
This	O
can	O
be	O
seen	O
as	O
the	O
composition	B-Application
of	O
linear	O
functions	O
and	O
the	O
softmax	B-Algorithm
function	I-Algorithm
(	O
where	O
denotes	O
the	O
inner	O
product	O
of	O
and	O
)	O
.	O
</s>
<s>
The	O
standard	O
softmax	B-Algorithm
function	I-Algorithm
is	O
often	O
used	O
in	O
the	O
final	O
layer	O
of	O
a	O
neural	O
network-based	O
classifier	O
.	O
</s>
<s>
the	O
derivative	O
of	O
a	O
sigmoid	B-Algorithm
function	I-Algorithm
,	O
being	O
expressed	O
via	O
the	O
function	O
itself	O
)	O
.	O
</s>
<s>
See	O
multinomial	O
logit	O
for	O
a	O
probability	O
model	O
which	O
uses	O
the	O
softmax	B-Algorithm
activation	I-Algorithm
function	I-Algorithm
.	O
</s>
<s>
In	O
the	O
field	O
of	O
reinforcement	O
learning	O
,	O
a	O
softmax	B-Algorithm
function	I-Algorithm
can	O
be	O
used	O
to	O
convert	O
values	O
into	O
action	O
probabilities	O
.	O
</s>
<s>
In	O
neural	B-Architecture
network	I-Architecture
applications	O
,	O
the	O
number	O
of	O
possible	O
outcomes	O
is	O
often	O
large	O
,	O
e.g.	O
</s>
<s>
in	O
case	O
of	O
neural	B-Language
language	I-Language
models	I-Language
that	O
predict	O
the	O
most	O
likely	O
outcome	O
out	O
of	O
a	O
vocabulary	O
which	O
might	O
contain	O
millions	O
of	O
possible	O
words	O
.	O
</s>
<s>
the	O
matrix	O
multiplications	O
to	O
determine	O
the	O
,	O
followed	O
by	O
the	O
application	O
of	O
the	O
softmax	B-Algorithm
function	I-Algorithm
itself	O
)	O
computationally	O
expensive	O
.	O
</s>
<s>
What	O
's	O
more	O
,	O
the	O
gradient	B-Algorithm
descent	I-Algorithm
backpropagation	B-Algorithm
method	O
for	O
training	O
such	O
a	O
neural	B-Architecture
network	I-Architecture
involves	O
calculating	O
the	O
softmax	O
for	O
every	O
training	O
example	O
,	O
and	O
the	O
number	O
of	O
training	O
examples	O
can	O
also	O
become	O
large	O
.	O
</s>
<s>
The	O
computational	O
effort	O
for	O
the	O
softmax	O
became	O
a	O
major	O
limiting	O
factor	O
in	O
the	O
development	O
of	O
larger	O
neural	B-Language
language	I-Language
models	I-Language
,	O
motivating	O
various	O
remedies	O
to	O
reduce	O
training	O
times	O
.	O
</s>
<s>
A	O
Huffman	B-General_Concept
tree	I-General_Concept
was	O
used	O
for	O
this	O
in	O
Google	O
's	O
word2vec	B-Algorithm
models	O
(	O
introduced	O
in	O
2013	O
)	O
to	O
achieve	O
scalability	O
.	O
</s>
<s>
Geometrically	O
the	O
softmax	B-Algorithm
function	I-Algorithm
maps	O
the	O
vector	O
space	O
to	O
the	O
boundary	O
of	O
the	O
standard	O
-simplex	O
,	O
cutting	O
the	O
dimension	O
by	O
one	O
(	O
the	O
range	O
is	O
a	O
-dimensional	O
simplex	O
in	O
-dimensional	O
space	O
)	O
,	O
due	O
to	O
the	O
linear	O
constraint	O
that	O
all	O
output	O
sum	O
to	O
1	O
meaning	O
it	O
lies	O
on	O
a	O
hyperplane	O
.	O
</s>
<s>
The	O
softmax	B-Algorithm
function	I-Algorithm
is	O
also	O
the	O
gradient	O
of	O
the	O
LogSumExp	O
function	O
,	O
a	O
smooth	O
maximum	O
:	O
</s>
<s>
The	O
softmax	B-Algorithm
function	I-Algorithm
was	O
used	O
in	O
statistical	O
mechanics	O
as	O
the	O
Boltzmann	O
distribution	O
in	O
the	O
foundational	O
paper	O
,	O
formalized	O
and	O
popularized	O
in	O
the	O
influential	O
textbook	O
.	O
</s>
<s>
Computation	O
of	O
this	O
example	O
using	O
Python	B-Language
code	I-Language
:	O
</s>
<s>
Here	O
is	O
an	O
example	O
of	O
Julia	B-Application
code	O
:	O
</s>
<s>
Here	O
is	O
an	O
example	O
of	O
R	B-Language
code	I-Language
:	O
</s>
<s>
Here	O
is	O
an	O
example	O
of	O
Elixir	B-Language
code	O
:	O
</s>
<s>
Here	O
is	O
an	O
example	O
of	O
Raku	B-Application
code	O
:	O
</s>
