Notes

Mixup

Mixup teaches a network that training examples need not be treated as isolated, all-or-nothing facts. Instead of showing it one example with one hard label at a time, it creates plausible points between pairs of examples and asks the model to behave smoothly there.

How the mixing works

Given two training pairs, (xi, yi) and (xj, yj), Mixup builds a new pair:

  • x̃ = λxi + (1 − λ)xj
  • ỹ = λyi + (1 − λ)yj

Here, λ is sampled from a Beta(α, α) distribution. The input is a weighted blend, and its target is the same weighted blend of one-hot labels. For example, a 70/30 input blend of classes A and B receives the soft target 70% A, 30% B. Training with cross-entropy then penalizes a model that is extremely confident in only one class.

Why it regularizes learning

A large network can memorize sharp, accidental details of individual examples. Mixup discourages abrupt decision boundaries by requiring predictions between examples to change roughly linearly. This reduces overconfidence, improves robustness to small distribution shifts, and can improve calibrated probabilities. It is architecture- and modality-agnostic: the same operation can mix feature vectors, images, or compatible continuous representations. In a PyTorch training loop, Mixup is usually applied to each minibatch before the forward pass; the loss is computed against the soft mixed targets.

Choices and trade-offs

The parameter α controls mixing strength. A small value produces mostly near-original examples; a larger value creates more balanced blends. Too little mixing provides weak regularization, while overly aggressive mixing can erase meaningful structure and slow fitting. Mixup also changes what a “correct” target means during training: dropout remains disabled at inference as usual, but Mixup itself is normally training-only. Unlike CutMix, which replaces a region with one from another example, Mixup blends every input value; that can create unrealistic-looking inputs, yet the smoothness constraint is precisely the useful training signal.

Mixup is a data-augmentation regularization method that creates synthetic training examples by linearly interpolating pairs of inputs and their labels. Given two samples, it trains the network on a weighted combination of both, with the same weights applied to their target vectors. Mixup encourages smoother decision boundaries, reduces memorization and overconfident predictions, and improves generalization by constraining behavior between observed training examples.

Imagine teaching someone to tell cats from dogs. Instead of showing only clear cat and dog photos, you occasionally show a blended picture: perhaps 70% cat and 30% dog. You tell them, “This is mostly a cat, but a little like a dog.”

Mixup is a training trick based on that idea. It combines two training examples and also combines their answers in the same proportion. This encourages a neural network to learn broader, smoother patterns rather than memorising individual pictures or examples. As a result, it is often less easily fooled by small changes and better at handling new data it has never seen before.