MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / compute_grad_norm

Function compute_grad_norm

PATH/core/utils.py:319–326  ·  view source on GitHub ↗
(parameters)

Source from the content-addressed store, hash-verified

317 p.grad.data.clamp_(min=-clip_value, max=clip_value)
318
319def compute_grad_norm(parameters):
320 parameters = list(filter(lambda p: p.grad is not None, parameters))
321 total_norm = 0
322 for p in parameters:
323 param_norm = p.grad.data.norm(2)
324 total_norm += param_norm ** 2
325 total_norm = total_norm ** 0.5
326 return total_norm
327
328
329class SIMSELoss(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected