torch.nn.utils.get_total_norm — PyTorch 2.7 documentation (original) (raw)

torch.nn.utils.get_total_norm(tensors, norm_type=2.0, error_if_nonfinite=False, foreach=None)[source]

Compute the norm of an iterable of tensors.

The norm is computed over the norms of the individual tensors, as if the norms of the individual tensors were concatenated into a single vector.

Parameters

Returns

Total norm of the tensors (viewed as a single vector).

Return type

Tensor