PyTorch的clip_grad_norm和clip_grad_norm_,有下划线时有什么区别?
在 torch.nn.utils
中编码 PyTorch 时,我看到两个函数,clip_grad_norm
和 clip_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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.