当前位置:   article > 正文

clone、new_tensor 等张量复制操作_new_tensor() 函数

new_tensor() 函数
  1. out = self.student(*inputs)
  2. self.last_students_logits = out.new_tensor(out, requires_grad=True)

 

  1. out = self.student(*inputs)
  2. self.last_students_logits = out.clone()

 

new_tensor   其默认参数下的操作等同于.clone().detach()

requires_grad=True 时的效果相当于.clone().detach().requires_grad_(True)

 

 

 

More  

1 对比clone、detach以及copy_等张量复制操作

https://blog.csdn.net/qq_40438388/article/details/106860180

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/272404
推荐阅读
相关标签
  

闽ICP备14008679号