torch / nn / torch.nn
torch.nn.utils.clip_grad_norm_¶
-
torch.nn.utils.
clip_grad_norm_
(parameters: Union[torch.Tensor, Iterable[torch.Tensor]], max_norm: float, norm_type: float = 2.0) → torch.Tensor[source]¶ Clips gradient norm of an iterable of parameters.
The norm is computed over all gradients together, as if they were concatenated into a single vector. Gradients are modified in-place.
- Parameters
- Returns
Total norm of the parameters (viewed as a single vector).
此页内容是否对您有帮助