Documentation

CslibFrontier.MachineLearning.OnlineLearning.AdaGrad

Adaptive online gradient descent (AdaGrad) #

Self-tuning, data-dependent online gradient descent [Hazan2022, Orabona2019]: instead of tuning a step size using an a priori gradient norm bound G and horizon T, AdaGrad accumulates the squared gradient norms seen so far and scales the step size inversely by their square root. All regret bounds below are derived from the adaptive local-norm OMD framework in CslibFrontier.MachineLearning.OnlineLearning.OnlineMirrorDescent.

Main definitions #

Main results #

References #

Exact section, theorem, and page locators below are unverified against primary PDFs (pending an outside-fleet source check).

theorem Cslib.MachineLearning.OnlineLearning.OCO.sum_div_sqrt_cumsum_le {a : ℕ → ℝ} (ha : ∀ (t : ℕ), 0 ≤ a t) {ε : ℝ} (hε : 0 ≤ ε) (T : ℕ) :
∑ t ∈ Finset.range T, a t / √(ε + ∑ s ∈ Finset.range (t + 1), a s) ≤ 2 * (√(ε + ∑ t ∈ Finset.range T, a t) - √ε)

Telescoping square-root lemma for adaptive gradient methods: for any nonnegative sequence a : ℕ → ℝ and ε ≥ 0, ∑ t ∈ range T, a t / √(ε + ∑ s ∈ range (t + 1), a s) ≤ 2 * (√(ε + ∑ t ∈ range T, a t) - √ε). Works even at ε = 0 when an initial prefix of a vanishes (using 0 / 0 = 0).

Named state of scalar AdaGrad-Norm: current iterate and accumulated squared gradient norm.

  • point : E

    Current decision point in E.

  • sqGradSum : ℝ

    Accumulated sum ε + ∑ s < t, ‖grad s (point s)‖ ^ 2.

noncomputable def Cslib.MachineLearning.OnlineLearning.OCO.adaGradNormState {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (proj : E → E) (grad : ℕ → E → E) (γ ε : ℝ) (x₀ : E) :

Full causal state sequence of scalar AdaGrad-Norm starting at (x₀, ε) with scale γ.

noncomputable def Cslib.MachineLearning.OnlineLearning.OCO.adaGradNorm {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (proj : E → E) (grad : ℕ → E → E) (γ ε : ℝ) (x₀ : E) (t : ℕ) :
E

Decision point sequence of scalar AdaGrad-Norm.

noncomputable def Cslib.MachineLearning.OnlineLearning.OCO.adaGradNormSqSum {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (proj : E → E) (grad : ℕ → E → E) (γ ε : ℝ) (x₀ : E) (t : ℕ) :

Accumulated squared gradient norm ε + ∑ s < t, ‖grad s (x s)‖ ^ 2 of scalar AdaGrad-Norm.

@[simp]
theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradNorm_zero {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (proj : E → E) (grad : ℕ → E → E) (γ ε : ℝ) (x₀ : E) :
adaGradNorm proj grad γ ε x₀ 0 = x₀
@[simp]
theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradNormSqSum_zero {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (proj : E → E) (grad : ℕ → E → E) (γ ε : ℝ) (x₀ : E) :
adaGradNormSqSum proj grad γ ε x₀ 0 = ε
theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradNormSqSum_succ {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (proj : E → E) (grad : ℕ → E → E) (γ ε : ℝ) (x₀ : E) (t : ℕ) :
adaGradNormSqSum proj grad γ ε x₀ (t + 1) = adaGradNormSqSum proj grad γ ε x₀ t + ‖grad t (adaGradNorm proj grad γ ε x₀ t)‖ ^ 2
theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradNorm_succ {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (proj : E → E) (grad : ℕ → E → E) (γ ε : ℝ) (x₀ : E) (t : ℕ) :
adaGradNorm proj grad γ ε x₀ (t + 1) = proj (adaGradNorm proj grad γ ε x₀ t - (γ / √(adaGradNormSqSum proj grad γ ε x₀ (t + 1))) • grad t (adaGradNorm proj grad γ ε x₀ t))
theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradNormSqSum_eq {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (proj : E → E) (grad : ℕ → E → E) (γ ε : ℝ) (x₀ : E) (t : ℕ) :
adaGradNormSqSum proj grad γ ε x₀ t = ε + ∑ s ∈ Finset.range t, ‖grad s (adaGradNorm proj grad γ ε x₀ s)‖ ^ 2
theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradNorm_mem {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {K : Set E} {proj : E → E} (hP : IsPythagoreanProjection K proj) {x₀ : E} (hx₀ : x₀ ∈ K) (grad : ℕ → E → E) (γ ε : ℝ) (t : ℕ) :
adaGradNorm proj grad γ ε x₀ t ∈ K
theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradNorm_dynamic_sum_inner_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {K : Set E} {proj : E → E} (hP : IsPythagoreanProjection K proj) {x₀ : E} (hx₀ : x₀ ∈ K) {D γ ε : ℝ} (hD : ∀ x ∈ K, ∀ y ∈ K, ‖x - y‖ ≤ D) (hγ : 0 < γ) (hε : 0 ≤ ε) {grad : ℕ → E → E} {u : ℕ → E} (hu : ∀ (t : ℕ), u t ∈ K) (T : ℕ) :
∑ t ∈ Finset.range T, inner ℝ (grad t (adaGradNorm proj grad γ ε x₀ t)) (adaGradNorm proj grad γ ε x₀ t - u t) ≤ (D ^ 2 / (2 * γ) + D / γ * pathLength u T + γ) * √(ε + ∑ t ∈ Finset.range T, ‖grad t (adaGradNorm proj grad γ ε x₀ t)‖ ^ 2) - γ * √ε

Linearized dynamic regret bound for scalar AdaGrad-Norm against any sequence of comparators u : ℕ → E in K.

theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradNorm_dynamic_regret_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {K : Set E} {proj : E → E} {f : ℕ → E → ℝ} {grad : ℕ → E → E} (hP : IsPythagoreanProjection K proj) {x₀ : E} (hx₀ : x₀ ∈ K) {D γ ε : ℝ} (hD : ∀ x ∈ K, ∀ y ∈ K, ‖x - y‖ ≤ D) (hγ : 0 < γ) (hε : 0 ≤ ε) (hsub : ∀ (t : ℕ), ∀ x ∈ K, ∀ y ∈ K, f t x + inner ℝ (grad t x) (y - x) ≤ f t y) {u : ℕ → E} (hu : ∀ (t : ℕ), u t ∈ K) (T : ℕ) :
∑ t ∈ Finset.range T, (f t (adaGradNorm proj grad γ ε x₀ t) - f t (u t)) ≤ (D ^ 2 / (2 * γ) + D / γ * pathLength u T + γ) * √(ε + ∑ t ∈ Finset.range T, ‖grad t (adaGradNorm proj grad γ ε x₀ t)‖ ^ 2) - γ * √ε

Dynamic regret of AdaGrad-Norm: without knowing a gradient bound G or horizon T, scalar AdaGrad-Norm incurs data-dependent regret against any sequence u in K.

theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradNorm_regret_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {K : Set E} {proj : E → E} {f : ℕ → E → ℝ} {grad : ℕ → E → E} (hP : IsPythagoreanProjection K proj) {x₀ : E} (hx₀ : x₀ ∈ K) {D γ ε : ℝ} (hD : ∀ x ∈ K, ∀ y ∈ K, ‖x - y‖ ≤ D) (hγ : 0 < γ) (hε : 0 ≤ ε) (hsub : ∀ (t : ℕ), ∀ x ∈ K, ∀ y ∈ K, f t x + inner ℝ (grad t x) (y - x) ≤ f t y) {u : E} (hu : u ∈ K) (T : ℕ) :
∑ t ∈ Finset.range T, (f t (adaGradNorm proj grad γ ε x₀ t) - f t u) ≤ (D ^ 2 / (2 * γ) + γ) * √(ε + ∑ t ∈ Finset.range T, ‖grad t (adaGradNorm proj grad γ ε x₀ t)‖ ^ 2) - γ * √ε

Static regret of AdaGrad-Norm [Ora19]: for any scale γ > 0 and offset ε ≥ 0, regret against every comparator u ∈ K is at most (D ^ 2 / (2 * γ) + γ) * √(ε + ∑ t < T, ‖grad t (x t)‖ ^ 2) - γ * √ε.

theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradNorm_regret_le_optimal {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {K : Set E} {proj : E → E} {f : ℕ → E → ℝ} {grad : ℕ → E → E} (hP : IsPythagoreanProjection K proj) {x₀ : E} (hx₀ : x₀ ∈ K) {D ε : ℝ} (hD0 : 0 < D) (hD : ∀ x ∈ K, ∀ y ∈ K, ‖x - y‖ ≤ D) (hε : 0 ≤ ε) (hsub : ∀ (t : ℕ), ∀ x ∈ K, ∀ y ∈ K, f t x + inner ℝ (grad t x) (y - x) ≤ f t y) {u : E} (hu : u ∈ K) (T : ℕ) :
∑ t ∈ Finset.range T, (f t (adaGradNorm proj grad (D / √2) ε x₀ t) - f t u) ≤ √2 * D * √(ε + ∑ t ∈ Finset.range T, ‖grad t (adaGradNorm proj grad (D / √2) ε x₀ t)‖ ^ 2) - D / √2 * √ε

Optimally scaled AdaGrad-Norm: choosing γ = D / √2 minimizes D ^ 2 / (2 * γ) + γ to √2 * D, giving data-dependent regret at most √2 * D * √(ε + ∑ t < T, ‖grad t (x t)‖ ^ 2) - (D / √2) * √ε without prior knowledge of G or T.

theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradNorm_regret_le_sqrt {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {K : Set E} {proj : E → E} {f : ℕ → E → ℝ} {grad : ℕ → E → E} (hP : IsPythagoreanProjection K proj) {x₀ : E} (hx₀ : x₀ ∈ K) {D G : ℝ} (hD0 : 0 < D) (hG0 : 0 ≤ G) (hD : ∀ x ∈ K, ∀ y ∈ K, ‖x - y‖ ≤ D) (hG : ∀ (t : ℕ), ∀ x ∈ K, ‖grad t x‖ ≤ G) (hsub : ∀ (t : ℕ), ∀ x ∈ K, ∀ y ∈ K, f t x + inner ℝ (grad t x) (y - x) ≤ f t y) {u : E} (hu : u ∈ K) (T : ℕ) :
∑ t ∈ Finset.range T, (f t (adaGradNorm proj grad (D / √2) 0 x₀ t) - f t u) ≤ √2 * G * D * √↑T

Worst-case O(G * D * √T) bound for AdaGrad-Norm: when ‖grad t x‖ ≤ G on K and ε = 0, AdaGrad-Norm with γ = D / √2 guarantees regret at most √2 * G * D * √T.

theorem Cslib.MachineLearning.OnlineLearning.OCO.exists_isAdaptiveOMDStep_diag {ι : Type u_1} [Fintype ι] {K : Set (EuclideanSpace ℝ ι)} (hne : K.Nonempty) (hc : IsComplete K) (hK : Convex ℝ K) {w : ι → ℝ} (hw : ∀ (i : ι), 0 < w i) (g x : EuclideanSpace ℝ ι) :
∃ (x' : EuclideanSpace ℝ ι), IsAdaptiveOMDStep K (fun (z : EuclideanSpace ℝ ι) => WithLp.toLp 2 fun (i : ι) => w i * z.ofLp i) g x x'

On any nonempty complete convex set K ⊆ EuclideanSpace ℝ ι, an adaptive diagonal OMD step exists for every strictly positive coordinate weight vector w : ι → ℝ.

theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradDiag_regret_le {ι : Type u_1} [Fintype ι] {K : Set (EuclideanSpace ℝ ι)} {D : ι → ℝ} (hD : ∀ a ∈ K, ∀ b ∈ K, ∀ (i : ι), |a.ofLp i - b.ofLp i| ≤ D i) {f : ℕ → EuclideanSpace ℝ ι → ℝ} {grad : ℕ → EuclideanSpace ℝ ι → EuclideanSpace ℝ ι} {x : ℕ → EuclideanSpace ℝ ι} {u : EuclideanSpace ℝ ι} (hx₀ : x 0 ∈ K) (hu : u ∈ K) {γ ε : ℝ} (hγ : 0 < γ) (hε : 0 ≤ ε) (T : ℕ) (hstep : ∀ t < T, IsAdaptiveOMDStep K (fun (z : EuclideanSpace ℝ ι) => WithLp.toLp 2 fun (i : ι) => √(ε + ∑ k ∈ Finset.range (t + 1), (grad k (x k)).ofLp i ^ 2) / γ * z.ofLp i) (grad t (x t)) (x t) (x (t + 1))) (hsub : ∀ t < T, ∀ a ∈ K, ∀ b ∈ K, f t a + inner ℝ (grad t a) (b - a) ≤ f t b) :
∑ t ∈ Finset.range T, (f t (x t) - f t u) ≤ ∑ i : ι, (D i ^ 2 / (2 * γ) + γ) * √(ε + ∑ t ∈ Finset.range T, (grad t (x t)).ofLp i ^ 2) - γ * ↑(Fintype.card ι) * √ε

General diagonal AdaGrad regret on an arbitrary coordinate-bounded convex set [Hazan2022, Orabona2019] (locators unverified): for any K ⊆ EuclideanSpace ℝ ι whose coordinate widths satisfy |a i - b i| ≤ D i on K, any γ > 0, ε ≥ 0, and any iterate sequence x satisfying the diagonal adaptive OMD step with weights √(ε + ∑ k ≤ t, (grad k (x k) i) ^ 2) / γ, the regret against every u ∈ K is at most ∑ i, ((D i) ^ 2 / (2 * γ) + γ) * √(ε + ∑ t < T, (grad t (x t) i) ^ 2) - γ * card ι * √ε.

Unlike adaGradBox_regret_le, K need not be an axis-aligned box.

theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradDiag_regret_le_optimal {ι : Type u_1} [Fintype ι] {K : Set (EuclideanSpace ℝ ι)} {D ε : ℝ} (hD0 : 0 < D) (hD : ∀ a ∈ K, ∀ b ∈ K, ∀ (i : ι), |a.ofLp i - b.ofLp i| ≤ D) (hε : 0 ≤ ε) {f : ℕ → EuclideanSpace ℝ ι → ℝ} {grad : ℕ → EuclideanSpace ℝ ι → EuclideanSpace ℝ ι} {x : ℕ → EuclideanSpace ℝ ι} {u : EuclideanSpace ℝ ι} (hx₀ : x 0 ∈ K) (hu : u ∈ K) (T : ℕ) (hstep : ∀ t < T, IsAdaptiveOMDStep K (fun (z : EuclideanSpace ℝ ι) => WithLp.toLp 2 fun (i : ι) => √(ε + ∑ k ∈ Finset.range (t + 1), (grad k (x k)).ofLp i ^ 2) / (D / √2) * z.ofLp i) (grad t (x t)) (x t) (x (t + 1))) (hsub : ∀ t < T, ∀ a ∈ K, ∀ b ∈ K, f t a + inner ℝ (grad t a) (b - a) ≤ f t b) :
∑ t ∈ Finset.range T, (f t (x t) - f t u) ≤ √2 * D * ∑ i : ι, √(ε + ∑ t ∈ Finset.range T, (grad t (x t)).ofLp i ^ 2) - D / √2 * ↑(Fintype.card ι) * √ε

Optimally scaled general diagonal AdaGrad on an ℓ∞-bounded convex domain: whenever |a i - b i| ≤ D for all a, b ∈ K and i : ι with D > 0, choosing γ = D / √2 gives √2 * D * ∑ i, √(ε + ∑ t < T, (grad t (x t) i) ^ 2) - D / √2 * card ι * √ε.

One-dimensional projection clamping a real number into [a, b].

clampProj a b is a Pythagorean projection onto Set.Icc a b whenever a ≤ b.

State of coordinate-wise diagonal AdaGrad on an axis-aligned box over ι.

  • point : ι → ℝ

    Current iterate ι → ℝ.

  • sqGradSum : ι → ℝ

    Per-coordinate accumulated sum ε + ∑ s < t, (grad s (point s) i) ^ 2.

@[reducible, inline]
abbrev Cslib.MachineLearning.OnlineLearning.OCO.Box {ι : Type u_1} (l r : ι → ℝ) :
Set (ι → ℝ)

Axis-aligned box ∏ i, [l i, r i].

noncomputable def Cslib.MachineLearning.OnlineLearning.OCO.adaGradBoxState {ι : Type u_1} (l r : ι → ℝ) (grad : ℕ → (ι → ℝ) → ι → ℝ) (γ ε : ℝ) (x₀ : ι → ℝ) :

Full causal state sequence of diagonal AdaGrad on the box Box l r with scale γ and offset ε [Haz22].

noncomputable def Cslib.MachineLearning.OnlineLearning.OCO.adaGradBox {ι : Type u_1} (l r : ι → ℝ) (grad : ℕ → (ι → ℝ) → ι → ℝ) (γ ε : ℝ) (x₀ : ι → ℝ) (t : ℕ) :
ι → ℝ

Iterate sequence of coordinate-wise diagonal AdaGrad on Box l r.

theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradBox_mem {ι : Type u_1} {l r : ι → ℝ} (hlr : ∀ (i : ι), l i ≤ r i) (grad : ℕ → (ι → ℝ) → ι → ℝ) (γ ε : ℝ) {x₀ : ι → ℝ} (hx₀ : x₀ ∈ Box l r) (t : ℕ) :
adaGradBox l r grad γ ε x₀ t ∈ Box l r
theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradBox_regret_le {ι : Type u_1} [Fintype ι] {l r : ι → ℝ} (hlr : ∀ (i : ι), l i ≤ r i) {f : ℕ → (ι → ℝ) → ℝ} {grad : ℕ → (ι → ℝ) → ι → ℝ} {x₀ u : ι → ℝ} (hx₀ : x₀ ∈ Box l r) (hu : u ∈ Box l r) {γ ε : ℝ} (hγ : 0 < γ) (hε : 0 ≤ ε) (hsub : ∀ (t : ℕ), ∀ x ∈ Box l r, ∀ y ∈ Box l r, f t x + ∑ i : ι, grad t x i * (y i - x i) ≤ f t y) (T : ℕ) :
∑ t ∈ Finset.range T, (f t (adaGradBox l r grad γ ε x₀ t) - f t u) ≤ ∑ i : ι, ((r i - l i) ^ 2 / (2 * γ) + γ) * √(ε + ∑ t ∈ Finset.range T, grad t (adaGradBox l r grad γ ε x₀ t) i ^ 2) - γ * ↑(Fintype.card ι) * √ε

Diagonal AdaGrad regret on an axis-aligned box [Haz22]: each coordinate runs an independent adaptive step size γ / √(ε + ∑ s ≤ t, (grad s (x s) i) ^ 2). With no prior bound on the gradient norms, the regret decomposes per coordinate as ∑ i, ((r i - l i) ^ 2 / (2 * γ) + γ) * √(ε + ∑ t < T, (grad t (x t) i) ^ 2) - γ * card ι * √ε.

theorem Cslib.MachineLearning.OnlineLearning.OCO.adaGradBox_regret_le_optimal {ι : Type u_1} [Fintype ι] {l r : ι → ℝ} (hlr : ∀ (i : ι), l i ≤ r i) {D ε : ℝ} (hD0 : 0 < D) (hwidth : ∀ (i : ι), r i - l i ≤ D) (hε : 0 ≤ ε) {f : ℕ → (ι → ℝ) → ℝ} {grad : ℕ → (ι → ℝ) → ι → ℝ} {x₀ u : ι → ℝ} (hx₀ : x₀ ∈ Box l r) (hu : u ∈ Box l r) (hsub : ∀ (t : ℕ), ∀ x ∈ Box l r, ∀ y ∈ Box l r, f t x + ∑ i : ι, grad t x i * (y i - x i) ≤ f t y) (T : ℕ) :
∑ t ∈ Finset.range T, (f t (adaGradBox l r grad (D / √2) ε x₀ t) - f t u) ≤ √2 * D * ∑ i : ι, √(ε + ∑ t ∈ Finset.range T, grad t (adaGradBox l r grad (D / √2) ε x₀ t) i ^ 2) - D / √2 * ↑(Fintype.card ι) * √ε

Optimally scaled diagonal AdaGrad on an ℓ∞-bounded box: when r i - l i ≤ D for every coordinate i : ι with D > 0, choosing γ = D / √2 gives √2 * D * ∑ i, √(ε + ∑ t < T, (grad t (x t) i) ^ 2) - D / √2 * card ι * √ε.