pytorch / 1 / generated / torch.nn.utils.clip_grad_value_.html

torch.nn.utils.clip_grad_value_

torch.nn.utils.clip_grad_value_(parameters, clip_value) [source]

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 [ -clip_value , clip_value ] \left[\text{-clip\_value}, \text{clip\_value}\right]

© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/1.13/generated/torch.nn.utils.clip_grad_value_.html