Skip to content
AI.info

Training and optimization

Sampling Policies, Curriculum, and Hard Examples

Understand shuffled sampling, stratification, curricula, hard-example mining, replay, and the risks of chasing noisy or adversarially difficult cases.

By the end you can

Visual

A data loader is an optimizer component

Selection probability determines which gradients are observed most often. Every policy in this lesson is judged the way the field eventually judged it: against a control condition that does not use it, on a fixed backbone or a fixed budget, with the numbers reported.

FigureProcess · 5 steps
  1. 1

    Define the candidate pool

    Choose eligible examples, groups, sequences, or replay items.

  2. 2

    Assign selection probabilities

    Use uniform, stratified, weighted, difficulty-based, or staged policies.

  3. 3

    Build the batch

    Respect grouping, sequence, diversity, and hardware constraints.

  4. 4

    Compute weighted gradients

    Correct or intentionally preserve the sampling bias.

  5. 5

    Update the sampling state

    Refresh difficulty scores, replay priorities, or curriculum phase.

Non-uniform sampling can change what objective is optimized

If examples are selected with unequal probabilities and no correction, frequent selections contribute more to the expected update. That may be intentional. It is not the original empirical average.

Importance weights can restore a target expectation under assumptions, yet they may increase variance. State the intended objective before choosing a sampler.

Selecting hard examples and re-weighting them are two different mechanisms, and they have been run against each other. Lin and colleagues held the backbone fixed — one ResNet-101-FPN — and swapped the two, at ICCV in 2017. The focal-loss paper states the difference exactly: “Like the focal loss, OHEM puts more emphasis on misclassified examples, but unlike FL, OHEM completely discards easy examples.” A sweep of the online hard example mining configurations reaches 32.8 AP on COCO at its best. Focal loss reaches 36.0 AP. The paper draws the conclusion in one line: “This is a gap of 3.2 AP, showing FL is more effective than OHEM for training dense detectors”. RetinaNet, the detector built on the re-weighted objective, reached 39.1 AP on COCO test-dev at 5 fps.

Down-weighting the easy examples beat discarding them, on the same network, by 3.2 AP. That is the size of the decision hiding inside the phrase “we mine hard examples”.

Sampling policy and loss weighting jointly define gradient emphasis.

Example

High loss has several meanings

A hard-example policy should classify difficulty before amplifying it. It should also ask how much data it has. The correct reading of a difficulty score reverses with dataset size.

That reversal was measured in 2022, in a data-pruning paper that NeurIPS named an Outstanding Paper. Sorscher, Geirhos and colleagues put it in one clause of a figure caption: “when data is abundant (scarce) ... the better pruning strategy is to keep the hard (easy) examples”. The scarce half is spelled out in the text: “If one does not have much data to start with, it is better to keep the easiest examples with largest margins (i.e. the blue regions of Fig. 1B) to avoid overfitting.” They predicted the switch analytically for the perceptron and confirmed it for a ResNet-18 on CIFAR-10.

The same score, the same examples, opposite policies.

  • Learnable boundary case: The example is rare but correctly labeled and reveals a useful distinction — the case a hard-example policy exists to find, and the one that pays in the data-abundant regime measured above.
  • Annotation error: The target conflicts with the input, so repeated emphasis is harmful. Northcutt and colleagues measured the base rate across ten widely used vision, language and audio benchmarks, and reported at NeurIPS in 2021: “Errors in test sets are numerous and widespread: we estimate an average of at least 3.3% errors across the 10 datasets, where for example label errors comprise at least 6% of the ImageNet validation set.” Crowdworkers confirmed 51% of the algorithmically flagged candidates as genuinely erroneous. That confirmed mass is precisely what a loss-driven sampler goes back for.
  • Irreducible ambiguity: Several outcomes are plausible, so a hard label is an inadequate target.
  • Pipeline artifact: Corrupted preprocessing or metadata creates an artificial high loss.
  • Distribution mismatch: The example belongs to a domain that needs separate modeling or explicit weighting.

Key idea

Difficulty-based sampling creates its own feedback loop

The model determines which examples appear hard, and those examples then shape the next model. Early mistakes or poorly calibrated losses can therefore concentrate attention incorrectly.

Use caps, diversity constraints, delayed score updates, and random exploration. Keep a uniform baseline path so the sampler cannot hide broad regressions.

FaceNet ran into this failure in 2015. Taking the hardest negative for each triplet did not sharpen the embedding. It destroyed it. The section on “Triplet Selection” records the outcome: “Selecting the hardest negatives can in practice lead to bad local minima early on in training, specifically it can result in a collapsed model (i.e. f(x) = 0).” The fix was not a different network. It was a cap on difficulty — “semi-hard” negatives, ones farther from the anchor than the positive — and the capped system reached 99.63% accuracy on Labeled Faces in the Wild and 95.12% on YouTube Faces DB.

The strongest available signal collapsed the model. The deliberately weakened one set the record.

A sampler that learns from the model can amplify the model’s blind spots.

Case

Two results bought by changing the sampler and nothing else

Changing only the sampler has produced two results worth carrying. Shrivastava and colleagues proposed online hard example mining in 2016; “combined with complementary advances in the field”, it “leads to state-of-the-art results of 78.9% and 76.3% mAP on PASCAL VOC 2007 and 2012 respectively”. Schaul and colleagues prioritized replay instead, reporting that “DQN with prioritized experience replay achieves a new state-of-the-art, outperforming DQN with uniform replay on 41 out of 49 games”. Neither team changed the network.

Both are also each team’s own claim about its own contribution. The isolation came later. In 2018 the Rainbow paper combined six DQN extensions — Schaul among its ten authors — and removed them one at a time across the 57-game Atari benchmark. The Analysis section reports the ranking: “Prioritized replay and multi-step learning were the two most crucial components of Rainbow, in that removing either component caused a large drop in median performance.”

Put in competition with five improvements to the network and the objective, a change to which stored transitions get sampled was one of the two the system could least afford to lose.

Comparison

Five ways to choose the next evidence

Each strategy creates a different learning distribution. And each risk in the table below has a documented instance rather than a hypothetical one: hard-example mining collapsed the FaceNet embedding, prioritized replay survived a 57-game ablation, and the curriculum row is the one that fails its own control.

FigureComparison · 5 columns

Uniform shuffle

Sample eligible examples with roughly equal probability.

  • Strength: simple baseline
  • Risk: rare groups sparse
  • State: little
  • Use: representative datasets

Stratified sampling

Control counts across labels, groups, or difficulty bins.

  • Strength: batch coverage
  • Risk: altered prevalence
  • State: group indices
  • Use: imbalanced settings

Curriculum

Change sampling from easier or stable cases toward harder conditions.

  • Strength: early stability
  • Risk: biased late coverage
  • State: phase or competence
  • Use: selected hard tasks

Hard-example mining

Prefer examples with high loss or ranking error.

  • Strength: focus useful mistakes
  • Risk: chase noise
  • State: difficulty scores
  • Use: detection and retrieval

Replay or priority buffer

Revisit stored examples according to recency or importance.

  • Strength: retain rare experience
  • Risk: stale distribution
  • State: buffer and priorities
  • Use: online or sequential learning

Visual

Evaluate a sampling policy beyond faster loss reduction

A useful policy should improve learning efficiency without erasing coverage.

Two of the steps below can live inside the sampler itself. Katharopoulos and Fleuret built them there, at ICML in 2018. Their method estimates the variance reduction importance sampling would achieve before using it, and switches on only when that reduction is real — step 2 as a runtime gate rather than a post-hoc log. They report the payoff the way step 3 demands, per unit wall-clock rather than per epoch: “for a fixed wall-clock time budget, it provides a reduction of the train losses of up to an order of magnitude and a relative improvement of test errors between 5% and 17%”.

A sampler that cannot state its gain at a matched budget has not been evaluated.

FigureProcess · 5 steps
  1. 1. Log exposure

    Record selection frequency by class, group, source, age, and difficulty.

  2. 2. Track correction weights

    Verify the effective contribution after sampling and reduction.

  3. 3. Compare matched budgets

    Use equal unique examples, tokens, compute, and validation access.

  4. 4. Inspect selected cases

    Measure noise, ambiguity, duplicates, and domain composition.

  5. 5. Test uniform fallback

    Confirm the model remains healthy when evaluated across the full intended distribution.

Analogy

A teacher choosing the next practice problem

Good teachers alternate foundational exercises, challenging problems, and review of past mistakes. Assigning only the hardest unsolved problem can stall learning.

A teacher knows which problems are hard. A sampler has only the current loss. That loss is noisy, it moves after every update, and it is reshaped by the choices the sampler just made. Pacing, coverage, and feedback matter as much here, but each has to be defended against the score that drives it. And as the abundant-versus-scarce reversal shows, the same score can call for opposite lesson plans depending on how much material there is.

Useful difficulty is a moving target that must be separated from bad evidence.

A curriculum is not always easy-to-hard

Some tasks benefit from broad diversity first, interleaving, or revisiting easier anchors after difficult phases. Difficulty can depend on the model, the target, and the desired representation.

Curriculum learning has a precise origin. Bengio and colleagues named it at ICML in 2009. Their experiments “show that significant improvements in generalization can be achieved”. The mechanism is stated as a hypothesis, not a result: an effect on “the speed of convergence of the training process to a minimum” and on “the quality of the local minima obtained”. Seventeen years on, that caution is still the right posture — because the control condition was eventually run.

Thousands of orderings settled it. Wu and colleagues swept curriculum, anti-curriculum and random-curriculum training, and presented the result at ICLR in 2021 as an Oral: “We find that for standard benchmark datasets, curricula have only marginal benefits, and that randomly ordered samples perform as well or better than curricula and anti-curricula, suggesting that any benefit is entirely due to the dynamic training set size.” Random order — the thing a curriculum is supposed to improve on — matched or beat both directions of ordering. Curriculum helped in two named conditions only: under a limited training-time budget, or with noisy data.

That is the shape of an honest claim. It is available because someone ran the ordering against a control instead of against nothing.

So treat curriculum order as an empirical policy with a control condition. Faster early convergence is not enough if final coverage or robustness suffers.

Curriculum design is sequencing evidence, not obeying one universal difficulty ladder.

Key takeaways