Gradient Clipping by Global Norm
~10 mincode completion
Implement clip_by_global_norm(grad_W, grad_b, max_norm) returning the clipped gradient as one flat array: grad_W flattened row by row, followed by grad_b.
Where this shows up
~10 min
••••••••••••••••
8 employers weight this skill
4 big tech firms, 2 quant funds, 1 frontier lab, 1 autonomy company. Top match scores 93.
Python
import numpy as np
def clip_by_global_norm(grad_W, grad_b, max_norm):
"""
Clip a model's gradients to a maximum global length.
Args:
grad_W: weight gradient, shape (m, n)
grad_b: bias gradient, shape (k,)
max_norm: the cap c
Returns:
flat array of length m * n + k: the clipped grad_W (row by row), then grad_b
"""
# YOUR CODE HERE
pass