Premium problem75. BatchNorm at Inference

Medium Locked

Build an nn.BatchNorm1d whose running statistics and affine parameters are set to the tensors given, put it in evaluation mode, and apply it to x of shape (B, D).

Return the output. In evaluation mode BatchNorm normalises with its stored running statistics rather than the batch's own, and must not update them -- which is why the mode matters more here than almost anywhere else.

Input

x =
tensor([[1., 2.],
        [3., 4.]])
running_mean = tensor([1., 1.])
running_var = tensor([4., 1.])
weight = tensor([2., 1.])
bias = tensor([0., 1.])
eps = 1e-05

Output

tensor([[0.0000, 2.0000],
        [2.0000, 4.0000]])

Premium problem

This one's part of Premium. Unlock the full PyTorch track plus every other premium problem on the site.

Implement solve(...)