All problems
Layer Normalized Embedding Vector
Problem
Layer normalization centers and scales a vector: (x - mean) / sqrt(variance + eps) using the population variance.
Given the vector and eps, return the normalized vector with gamma = 1 and beta = 0.
Hint
Center first, then divide by the root variance.
Test cases
case 1
in: [[1,2,3],0.000001]
expected: [-1.224743952833969,0,1.224743952833969]
case 2
in: [[0,0],0.000001]
expected: [0,0]
case 3
in: [[4,4,4,4],0.000001]
expected: [0,0,0,0]
Starter codePython
def layer_normalized_embedding_vector(x, eps):
# Your code here
pass3 test cases · run your code against them in the editor