Documentation

CslibFrontier.MachineLearning.OnlineLearning.MultiplicativeUpdate

Multiplicative updates for learning with experts #

A learner chooses among the experts ι (a nonempty finite type) in rounds t = 0, 1, …. In round t it plays a distribution on ι; then the loss vector ℓ t : ι → ℝ is revealed and the learner pays the expected loss ∑ i, prob φ ℓ t i * ℓ t i. A multiplicative update with factor φ gives expert i the weight ∏ s < t, φ (ℓ s i) (weight), and plays the weights normalized by their sum, the potential (potential, prob) [AroraHazanKale2012, §2]. The distribution in round t depends only on the losses of the rounds before t (prob_congr), so the learner is online. The factors 1 - η x (multiplicative weights) and exp (-η x) (Hedge) are the instances studied in the files MultiplicativeWeights and Hedge.

All bounds below hold for every loss sequence ℓ. They therefore cover an adaptive adversary, whose loss vector in each round depends on the learner's current distribution: such an adversary adv produces the loss sequence adaptiveLoss φ adv, which satisfies adaptiveLoss φ adv t = adv t (prob φ (adaptiveLoss φ adv) t) (adaptiveLoss_eq).

The analysis rests on one potential inequality (sum_log_le_log_card_add): the potential starts at n = card ι, is at least the weight of any single expert, and is multiplied in round t by the expected update factor ∑ i, prob φ ℓ t i * φ (ℓ t i). Taking logarithms, for every expert i, ∑ s < t, log φ (ℓ s i) ≤ log n + ∑ s < t, log (∑ j, prob φ ℓ s j * φ (ℓ s j)). This is the argument of [AroraHazanKale2012, proof of Theorem 2.1], stated once for every positive factor.

The tuned learning rate η = √(L / T) balances the two terms η T + L / η of the regret bounds at 2 √(T L) (sqrt_div_mul_add_div_sqrt_div).

The declarations of the experts setting live in the namespace Cslib.MachineLearning.OnlineLearning.Experts.

Main definitions #

Main results #

References #

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.weight {ι : Type u_1} (φ : ℝ → ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) (i : ι) :

The weight of expert i in round t under the multiplicative update with factor φ, against the losses ℓ: the product of the factors φ (ℓ s i) of the rounds s < t.

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.potential {ι : Type u_1} [Fintype ι] (φ : ℝ → ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) :

The potential in round t: the total weight of the experts.

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.prob {ι : Type u_1} [Fintype ι] (φ : ℝ → ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) (i : ι) :

The learner's distribution in round t: the weights normalized by the potential.

@[simp]
theorem Cslib.MachineLearning.OnlineLearning.Experts.weight_zero {ι : Type u_1} (φ : ℝ → ℝ) (ℓ : ℕ → ι → ℝ) (i : ι) :
weight φ ℓ 0 i = 1

Every expert starts with weight 1.

theorem Cslib.MachineLearning.OnlineLearning.Experts.weight_succ {ι : Type u_1} (φ : ℝ → ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) (i : ι) :
weight φ ℓ (t + 1) i = weight φ ℓ t i * φ (ℓ t i)

The weight is multiplied by the factor of the current loss.

@[simp]
theorem Cslib.MachineLearning.OnlineLearning.Experts.potential_zero {ι : Type u_1} [Fintype ι] (φ : ℝ → ℝ) (ℓ : ℕ → ι → ℝ) :
potential φ ℓ 0 = ↑(Fintype.card ι)

The potential starts at the number of experts.

theorem Cslib.MachineLearning.OnlineLearning.Experts.weight_congr {ι : Type u_1} {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} {ℓ' : ℕ → ι → ℝ} (h : ∀ s < t, ℓ s = ℓ' s) :
weight φ ℓ t = weight φ ℓ' t

The weights in round t depend only on the losses before round t.

theorem Cslib.MachineLearning.OnlineLearning.Experts.prob_congr {ι : Type u_1} [Fintype ι] {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} {ℓ' : ℕ → ι → ℝ} (h : ∀ s < t, ℓ s = ℓ' s) :
prob φ ℓ t = prob φ ℓ' t

The learner's distribution in round t depends only on the losses before round t.

theorem Cslib.MachineLearning.OnlineLearning.Experts.weight_pos {ι : Type u_1} {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} (hφ : ∀ s < t, ∀ (i : ι), 0 < φ (ℓ s i)) (i : ι) :
0 < weight φ ℓ t i

With positive factors, every weight is positive.

theorem Cslib.MachineLearning.OnlineLearning.Experts.potential_pos {ι : Type u_1} [Fintype ι] {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} [Nonempty ι] (hφ : ∀ s < t, ∀ (i : ι), 0 < φ (ℓ s i)) :
0 < potential φ ℓ t

With positive factors, the potential is positive.

theorem Cslib.MachineLearning.OnlineLearning.Experts.prob_nonneg {ι : Type u_1} [Fintype ι] {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} (hφ : ∀ s < t, ∀ (i : ι), 0 < φ (ℓ s i)) (i : ι) :
0 ≤ prob φ ℓ t i

With positive factors, the learner's probabilities are nonnegative.

theorem Cslib.MachineLearning.OnlineLearning.Experts.prob_pos {ι : Type u_1} [Fintype ι] {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} (hφ : ∀ s < t, ∀ (i : ι), 0 < φ (ℓ s i)) (i : ι) :
0 < prob φ ℓ t i

With positive factors, every expert has positive probability.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_prob {ι : Type u_1} [Fintype ι] {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} [Nonempty ι] (hφ : ∀ s < t, ∀ (i : ι), 0 < φ (ℓ s i)) :
∑ i : ι, prob φ ℓ t i = 1

With positive factors, the learner plays a probability distribution.

theorem Cslib.MachineLearning.OnlineLearning.Experts.potential_succ {ι : Type u_1} [Fintype ι] {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} [Nonempty ι] (hφ : ∀ s < t, ∀ (i : ι), 0 < φ (ℓ s i)) :
potential φ ℓ (t + 1) = potential φ ℓ t * ∑ i : ι, prob φ ℓ t i * φ (ℓ t i)

The potential is multiplied by the expected update factor.

theorem Cslib.MachineLearning.OnlineLearning.Experts.prob_succ {ι : Type u_1} [Fintype ι] {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} (hφ : ∀ s < t, ∀ (i : ι), 0 < φ (ℓ s i)) (i : ι) :
prob φ ℓ (t + 1) i = prob φ ℓ t i * φ (ℓ t i) / ∑ j : ι, prob φ ℓ t j * φ (ℓ t j)

The distribution is updated multiplicatively: the probability of expert i in round t + 1 is its probability in round t times its update factor, normalized by the expected update factor.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_prob_mul_pos {ι : Type u_1} [Fintype ι] {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} [Nonempty ι] (hφ : ∀ s < t + 1, ∀ (i : ι), 0 < φ (ℓ s i)) :
0 < ∑ i : ι, prob φ ℓ t i * φ (ℓ t i)

With positive factors, the expected update factor is positive.

theorem Cslib.MachineLearning.OnlineLearning.Experts.potential_eq_card_mul_prod {ι : Type u_1} [Fintype ι] {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} (hφ : ∀ s < t, ∀ (i : ι), 0 < φ (ℓ s i)) :
potential φ ℓ t = ↑(Fintype.card ι) * ∏ s ∈ Finset.range t, ∑ i : ι, prob φ ℓ s i * φ (ℓ s i)

The potential is n times the product of the expected update factors.

theorem Cslib.MachineLearning.OnlineLearning.Experts.log_potential {ι : Type u_1} [Fintype ι] {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} [Nonempty ι] (hφ : ∀ s < t, ∀ (i : ι), 0 < φ (ℓ s i)) :
Real.log (potential φ ℓ t) = Real.log ↑(Fintype.card ι) + ∑ s ∈ Finset.range t, Real.log (∑ i : ι, prob φ ℓ s i * φ (ℓ s i))

The logarithm of the potential: log n plus the logarithms of the expected update factors.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_log_le_log_card_add {ι : Type u_1} [Fintype ι] {φ : ℝ → ℝ} {ℓ : ℕ → ι → ℝ} {t : ℕ} [Nonempty ι] (hφ : ∀ s < t, ∀ (i : ι), 0 < φ (ℓ s i)) (i : ι) :
∑ s ∈ Finset.range t, Real.log (φ (ℓ s i)) ≤ Real.log ↑(Fintype.card ι) + ∑ s ∈ Finset.range t, Real.log (∑ j : ι, prob φ ℓ s j * φ (ℓ s j))

The potential inequality [AroraHazanKale2012, proof of Theorem 2.1]: the weight of any expert is at most the potential, so for every expert i, the logarithms of its update factors sum to at most log n plus the logarithms of the learner's expected update factors.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sqrt_div_mul_add_div_sqrt_div {L T : ℝ} (hL : 0 < L) (hT : 0 < T) :
√(L / T) * T + L / √(L / T) = 2 * √(T * L)

The tuned learning rate η = √(L / T) balances the two terms η T + L / η of a regret bound: their sum is then 2 √(T L).

Adaptive adversaries #

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.adaptiveWeight {ι : Type u_1} [Fintype ι] (φ : ℝ → ℝ) (adv : ℕ → (ι → ℝ) → ι → ℝ) :
ℕ → ι → ℝ

The weights against an adaptive adversary adv, which chooses the loss vector of round t as adv t p from the learner's current distribution p.

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.adaptiveLoss {ι : Type u_1} [Fintype ι] (φ : ℝ → ℝ) (adv : ℕ → (ι → ℝ) → ι → ℝ) (t : ℕ) :
ι → ℝ

The loss sequence produced by the adaptive adversary adv against the multiplicative update with factor φ.

theorem Cslib.MachineLearning.OnlineLearning.Experts.weight_adaptiveLoss {ι : Type u_1} [Fintype ι] (φ : ℝ → ℝ) (adv : ℕ → (ι → ℝ) → ι → ℝ) (t : ℕ) :
weight φ (adaptiveLoss φ adv) t = adaptiveWeight φ adv t

The weights against adaptiveLoss φ adv are the adaptive weights.

theorem Cslib.MachineLearning.OnlineLearning.Experts.adaptiveLoss_eq {ι : Type u_1} [Fintype ι] (φ : ℝ → ℝ) (adv : ℕ → (ι → ℝ) → ι → ℝ) (t : ℕ) :
adaptiveLoss φ adv t = adv t (prob φ (adaptiveLoss φ adv) t)

Against adaptiveLoss φ adv, the loss vector of round t is the adversary's response to the learner's distribution in round t. So the regret bounds, which hold for every loss sequence, hold against adaptive adversaries.