nn_utils_clip_grad_value_ function

Clips gradient of an iterable of parameters at specified value.

Clips gradient of an iterable of parameters at specified value.

Gradients are modified in-place.

nn_utils_clip_grad_value_(parameters, clip_value)

Arguments

  • 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.

Details

The gradients are clipped in the range [\mboxclip_value,\mboxclip_value]\left[\mbox{-clip\_value}, \mbox{clip\_value}\right]

  • Maintainer: Daniel Falbel
  • License: MIT + file LICENSE
  • Last published: 2025-02-14