PyTorch的clip_grad_norm和clip_grad_norm_,有下划线时有什么区别?

发布于 2025-01-16 20:17:45 字数 378 浏览 0 评论 0原文

torch.nn.utils 中编码 PyTorch 时,我看到两个函数,clip_grad_normclip_grad_norm_

我想知道其中的区别,所以我去检查文档,但是当我 搜索我只找到了clip_grad_norm_,而不是clip_grad_norm

所以我就来问问大家有没有人知道其中的区别。

When coding PyTorch in torch.nn.utils I see two functions, clip_grad_norm and clip_grad_norm_.

I want to know the difference so I went to check the documentation but when I searched I only found the clip_grad_norm_ and not clip_grad_norm.

So I'm here to ask if anyone knows the difference.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦断已成空 2025-01-23 20:17:45

Pytorch 使用尾随下划线约定进行就地操作。所以区别在于,带下划线的会修改张量,而另一个则保持原始张量不变并返回一个新的张量。

Pytorch uses the trailing underscore convention for in-place operations. So the difference is that the one with an underscore modifies the tensor in place and the other one leaves the original tensor unmodified and returns a new tensor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文