Skip to content
Glacius
OptimizationConcept reference

Unbiased gradients

A sampled gradient is unbiased for a target objective when its expectation, at fixed parameters, equals that objective's full gradient.

On this page 7 sections
  1. Overview
  2. Average over the sampling scheme
  3. Compare two sampling rules
  4. State which objective is targeted
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01Average over the sampling scheme#

A sampled gradient is unbiased for a target objective when its expectation, at fixed parameters, equals that objective's full gradient. The sampling probabilities are part of the claim.

For a mean loss over nn examples, the full gradient is the average of their gradients. Sampling one example uniformly gives that same average in expectation, because each example has probability 1/n1/n.

02Compare two sampling rules#

At fixed parameters, suppose two scalar example gradients are 2-2 and 8-8. The gradient of their mean objective is (28)/2=5(-2-8)/2=-5. Uniformly choosing either raw example gradient has expectation 5-5.

If the first example is chosen with probability 0.90.9 and the second with 0.10.1, the expected raw gradient becomes 0.9(2)+0.1(8)=2.60.9(-2)+0.1(-8)=-2.6. This sampling rule is biased for the original equally weighted objective.

Check your reasoning

Raw example gradients are −2,6, sampled with probabilities 0.75,0.25. Their expected sampled gradient?

  1. A0
  2. B2
  3. C4
Show answer and explanation
0

The weighted average is −1.5+1.5=0.

03State which objective is targeted#

The nonuniform sampler is unbiased for a different weighted objective whose weights are 0.9,0.10.9,0.1. Calling an estimator biased or unbiased requires naming the target, not merely examining whether the sample looks random.

For vector gradients, compare each coordinate's expectation. Unbiasedness does not make an individual draw equal to the full gradient, and it does not guarantee that every stochastic step decreases loss.

Check your reasoning

A sampler favors examples with large gradients but applies no correction. A draft calls it unbiased solely because all examples remain possible. What must be checked?

  1. AOnly whether probabilities are nonzero
  2. BThe probability-weighted expectation against the target gradient
  3. COnly the number of features
Show answer and explanation
The probability-weighted expectation against the target gradient

Unequal sampling can change the expected raw gradient.

Sampling convenient or easy examples can change the expected gradient. Importance weighting can correct some nonuniform schemes, but deriving such corrections is outside this lesson. Here, compute the expected supplied gradient under the stated probabilities and compare it with the intended target.

Key takeaway

Check an unbiased stochastic-gradient claim under a stated sampling scheme.

  • Check an unbiased stochastic-gradient claim under a stated sampling scheme.

Sources & further reading

  1. [1]
    Stanford CS229, Main Notes, Part I §1cs229.stanford.edu · Article
  2. [2]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Unbiased gradients.” Math behind ML. /learn/o-unbiased-gradient