The function below applies batch normalization, but has a bug when called in evaluation mode (training=False).
Signature: def buggy_batchnorm(x, gamma, beta, running_mean, running_var, training=False, eps=1e-5)
The contract: running_mean and running_var are the statistics accumulated during training and passed in by the caller. The output of a single sample at eval time must not depend on which other samples happen to share its batch.
Find and fix the bug.
Math
Asked at
import numpy as np
def buggy_batchnorm(...):
pass
Premium problem
Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.
Already premium?