Premium problem125. Layer Normalization Forward

Easy Locked

Given X of shape (n, d), scale gamma (d,), shift beta (d,) and eps, return the (n, d) layer-normalised output:

  • normalise each row to zero mean and unit variance, using the biased variance
  • then scale by gamma and shift by beta

Input

X =
[[ 1.  2.  3.]
 [10. 10. 16.]]
gamma = [1. 1. 1.]
beta = [0. 0. 0.]
eps = 1e-05

Output

[[-1.22473569  0.          1.22473569]
 [-0.70710634 -0.70710634  1.41421268]]

Premium problem

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

Implement solve(...)