Study Vault Search notes, aliases and full text
Graph
ConceptDBISAI-written · not yet proofread

Softmax

The softmax function maps a vector z ∈ ℝ^k to the probability distribution with components e^(z_i) / Σ_j e^(z_j).

Know these firstSigmoid

Properties#

  • softmax(z)i∈(0,1)\text{softmax}(z)_i \in (0, 1) for all ii, and ∑isoftmax(z)i=1\sum_i \text{softmax}(z)_i = 1.
  • Preserves ordering: if zi>zjz_i > z_j then softmax(z)i>softmax(z)j\text{softmax}(z)_i > \text{softmax}(z)_j. So arg⁡max⁡isoftmax(z)i=arg⁡max⁡izi\arg\max_i \text{softmax}(z)_i = \arg\max_i z_i.
  • Invariant under constant shift: softmax(z+c)=softmax(z)\text{softmax}(z + c) = \text{softmax}(z) for any scalar cc (the factor ece^c cancels). Implementations subtract max⁡izi\max_i z_i before exponentiating to avoid overflow.
  • Relation to Sigmoid (two-class case, exam WS 23/24, Task 5.3): softmax([x,0])1=exex+1=11+e−x=σ(x)\text{softmax}([x, 0])_1 = \frac{e^x}{e^x + 1} = \frac{1}{1 + e^{-x}} = \sigma(x) softmax([x,0])2=1ex+1=σ(−x)\text{softmax}([x, 0])_2 = \frac{1}{e^x + 1} = \sigma(-x) By shift invariance, any two scores (z1,z2)(z_1, z_2) give softmax(z)1=σ(z1−z2)\text{softmax}(z)_1 = \sigma(z_1 - z_2). Multi-class logistic regression with softmax over k=2k = 2 scores is therefore ordinary Logistic Regression.

Example#

softmax([2,1,0])=(e2e2+e+1,  ee2+e+1,  1e2+e+1)≈(0.665,0.245,0.090)\text{softmax}([2, 1, 0]) = \left(\frac{e^2}{e^2 + e + 1},\; \frac{e}{e^2 + e + 1},\; \frac{1}{e^2 + e + 1}\right) \approx (0.665, 0.245, 0.090)

Shifting by −2-2 gives the same result: softmax([0,−1,−2])=(1,e−1,e−2)1+e−1+e−2≈(0.665,0.245,0.090)\text{softmax}([0, -1, -2]) = \frac{(1, e^{-1}, e^{-2})}{1 + e^{-1} + e^{-2}} \approx (0.665, 0.245, 0.090).

Sources#

  • Not covered by a WS 25/26 lecture. Source: the DBIS exams.
  • Exam WS 23/24, Task 5.3 (not published) (softmax of (x,0)(x, 0) in terms of σ\sigma)

Search

Type In
↑ ↓ move ↵ open ⇥ next section Ctrl↵ results page Prefix # to search text only