All problems
Gradient Norm Under Scaling
Problem
If a gradient vector is uniformly scaled by a factor c, its Euclidean norm scales by |c|.
Given the unscaled gradient and the scale factor, return the norm of the scaled gradient.
Hint
Pull the absolute value of the scalar out of the norm.
Test cases
case 1
in: [[3,4],2]
expected: 10
case 2
in: [[1,0,0],-5]
expected: 5
case 3
in: [[0,0],7]
expected: 0
Starter codePython
def gradient_norm_under_scaling(grad, scale):
# Your code here
pass3 test cases · run your code against them in the editor