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

Function clip_grad_value

PATH/core/utils.py:314–317  ·  view source on GitHub ↗
(parameters, clip_value)

Source from the content-addressed store, hash-verified

312 return bn_group, feature_group, fc_group, normal_group
313
314def clip_grad_value(parameters, clip_value):
315 clip_value = float(clip_value)
316 for p in filter(lambda p: p.grad is not None, parameters):
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))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected