Skip to content
Rainbow docs menu

Reference · The Applied Higher-Order Functions catalogue

rainbow.algorithms.proofs.ahof.softmax

The Applied Higher-Order Functions cataloguesrc/rainbow/algorithms/proofs/ahof/softmax.clj1 definitions, 2 theorems

AHoF Softmax: turn a vector of real-valued scores (logits) into a probability distribution over classes -- the standard output layer of multi-class classifiers and the policy head of policy-gradient RL. Each class probability is its exponentiated score divided by the sum of all exponentiated scores: softmax-share exp-score total-exp = exp-score / total-exp so the shares are classically non-negative and sum to one. Proved native and axiom-free: the softmax share as exact rational division of the score's exponential by the normalizer; a worked share 3 / 4 = 3/4; and the worked sum 3/4 + 1/4 = 1 of two complementary shares. The exponentials (a transcendental) are executable / supplied. That the shares sum to one for all inputs is not proved here. Requires nnrat/divide (rational-division capability, composed here), nnrat/add, nnrat/equivalent, and the D63 checkpoint. Scope (measured by the kernel): this module has 2 worked instances (statements about specific values). None of its theorems is a guarantee about the algorithm for all inputs; `lein verify rainbow.algorithms.proofs.ahof.softmax` prints this classification.

Depends onmath.rational.division

softmax/share

DefinitionSource, line 64

softmax/share :
  (x₁ x₂ : ℚ≥0)
  → ℚ≥0

ℚ≥0 = nnrat/NonnegativeRational

softmax/share-example

TheoremWorked exampleNo axiomsSource, line 75

softmax/share-example :
  → ols/slope 3 4 = 3/4

= = nnrat/equivalent: equality of rational values

softmax/shares-sum-to-one

TheoremWorked exampleNo axiomsSource, line 81

softmax/shares-sum-to-one :
  → ols/slope 3 4 + ols/slope 1 4 = 1

+ = nnrat/add= = nnrat/equivalent: equality of rational values