oneflow.nn.utils.clip_grad_value_

oneflow.nn.utils.clip_grad_value_(parameters: Union[oneflow.Tensor, Iterable[oneflow.Tensor]], clip_value: float)None

Clips gradient of an iterable of parameters at specified value.

Gradients are modified in-place.

Parameters
  • parameters (Iterable[Tensor] or Tensor) – an iterable of Tensors or a single Tensor that will have gradients normalized

  • clip_value (float or int) – maximum allowed value of the gradients. The gradients are clipped in the range \(\left[\text{-clip\_value}, \text{clip\_value}\right]\)