mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Address docs for clip_grad functions (#155125)
This PR takes the opinionated stance that `torch.nn.utils.<func>` should be the preferred API over `torch.nn.utils.clip_grad.<func>`. Pull Request resolved: https://github.com/pytorch/pytorch/pull/155125 Approved by: https://github.com/albanD, https://github.com/mikaylagawarecki, https://github.com/janeyx99
This commit is contained in:
committed by
PyTorch MergeBot
parent
dd41a3907c
commit
5e93abe3c0
@ -1297,10 +1297,6 @@ coverage_ignore_functions = [
|
||||
"scatter_kwargs",
|
||||
# torch.nn.parameter
|
||||
"is_lazy",
|
||||
# torch.nn.utils.clip_grad
|
||||
"clip_grad_norm",
|
||||
"clip_grad_norm_",
|
||||
"clip_grad_value_",
|
||||
# torch.nn.utils.convert_parameters
|
||||
"parameters_to_vector",
|
||||
"vector_to_parameters",
|
||||
|
@ -16,11 +16,7 @@ from torch.utils._foreach_utils import (
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"clip_grad_norm_",
|
||||
"clip_grad_norm",
|
||||
"clip_grad_value_",
|
||||
]
|
||||
__all__: list[str] = []
|
||||
|
||||
|
||||
_tensor_or_tensors = Union[
|
||||
@ -292,3 +288,8 @@ def clip_grad_value_(
|
||||
else:
|
||||
for grad in grads:
|
||||
cast(Tensor, grad).clamp_(min=-clip_value, max=clip_value)
|
||||
|
||||
|
||||
clip_grad_norm.__module__ = "torch.nn.utils"
|
||||
clip_grad_norm_.__module__ = "torch.nn.utils"
|
||||
clip_grad_value_.__module__ = "torch.nn.utils"
|
||||
|
Reference in New Issue
Block a user