Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-063

Parameter Norm L2

Problem

Compute the global L2 norm of a 2D parameter matrix: the square root of the sum of squared entries.

The signature is param_norm_l2(params).

Hint

Sum the squares of every entry before taking the square root.

Test cases

case 1
in: [[[3,4]]]
expected: 5
case 2
in: [[[1,0],[0,1]]]
expected: 1.4142135624
case 3
in: [[[0,0],[0,0]]]
expected: 0
case 4
in: [[[1,-2,2]]]
expected: 3
Starter codePython
import math
def param_norm_l2(params):
    # Your code here
    pass

4 test cases · run your code against them in the editor