Neural networks tend to memorize training images and become overconfident between them. Mixup is an augmentation that teaches them to behave linearly between examples: build a new training example as a weighted average of two images, and give it the same weighted average of their (one-hot) labels. A picture that is 70% cat and 30% dog gets the label "0.7 cat, 0.3 dog". The mixing weight lam is drawn from a Beta distribution with parameter alpha. Small alpha means lam is usually near 0 or 1 (a mild mix), and alpha = 1 makes it uniform on [0, 1].
Implement sample_lambda and mixup.
sample_lambda(alpha, rng) returns rng.beta(alpha, alpha) with exactly one call to rng.beta, where rng is a np.random.RandomState.mixup(x1, y1, x2, y2, lam) returns (lam * x1 + (1 - lam) * x2, lam * y1 + (1 - lam) * y2). Images and one-hot label vectors are NumPy arrays of matching shapes.lam is a float in [0, 1]. Do not modify the inputs.Mixup is a convex combination, so every pixel and label entry stays within the range of its two parents.
Labels must be one-hot (or soft) vectors, not integer class ids, so they can be averaged.
No results yet
Run your code to check it against the examples, or submit to run every test.