§B.9 — the softmax loss has gradient p(v) − e_y, Lipschitz constant √2 and smoothness constant 1
ProvedCertDRO.NNSmooth.softmax_constantsLet , , and let be the softmax loss on , with the vector of softmax probabilities. Then:
- is differentiable with gradient
- is -Lipschitz: for all ,
- if , this constant is the supremum of the gradient norm:
- the derivative of is -Lipschitz: for all ,
In the terminology of Assumption E, the softmax loss is a layer with and ; these are the constants that enter Corollary 4.
Formalization Note The paper states ; part 3 states this value of the supremum (a real supremum over a nonempty set bounded by ), which is not attained, under (for , and the supremum is ; the paper's "any corner other than " presumes a second class). The paper's "" is a bound, not the value of a supremum, and is stated as a bound. The paper's eigenvalue argument for (via and Weyl's inequality) is not formalized; only its conclusion, the bound with constant , is. The derivative in part 4 is the Fréchet derivative, a linear functional whose operator norm equals the Euclidean norm of the gradient. Classes are Fin K (0-based) and is EuclideanSpace.single y 1.
import Mathlib import Definitions.Def_CertDRO_NNSmooth_Softmax
namespace CertDRO.NNSmooth
/-- §B.9 (p. 46), the constants of the softmax loss `σ_y(v) = −log p_y(v)` on `ℝ^K`:
its gradient is `∇σ_y(v) = p(v) − e_y`; `σ_y` is `√2`-Lipschitz for the ℓ²-norm (`L⁰ = √2`);
for `K ≥ 2`, `sup_v ‖p(v) − e_y‖₂ = √2` (the supremum, not attained); and its derivative is
`1`-Lipschitz from the ℓ²-norm to the operator norm (`L¹ = 1`). -/
theorem softmax_constants {K : ℕ} (y : Fin K) :
(∀ v : EuclideanSpace ℝ (Fin K),
HasGradientAt (softmaxLoss y) (softmaxProb v - EuclideanSpace.single y 1) v) ∧
(∀ u v : EuclideanSpace ℝ (Fin K),
|softmaxLoss y u - softmaxLoss y v| ≤ Real.sqrt 2 * ‖u - v‖) ∧
(2 ≤ K → (⨆ v : EuclideanSpace ℝ (Fin K),
‖softmaxProb v - EuclideanSpace.single y 1‖) = Real.sqrt 2) ∧
(∀ u v : EuclideanSpace ℝ (Fin K),
‖fderiv ℝ (softmaxLoss y) u - fderiv ℝ (softmaxLoss y) v‖ ≤ 1 * ‖u - v‖) := by sorry
end CertDRO.NNSmooth
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.