当前位置:   article > 正文

UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach()

to copy construct from a tensor, it is recommended to use sourcetensor.clone

1、UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
在这里插入图片描述
解决:

theta_init_new = torch.tensor(theta, dtype=torch.float32, requires_grad=True)
  • 1

改为

theta_init_new = torch.as_tensor(theta, dtype=torch.float32, requires_grad=True)
  • 1

2、‘bool’ object is not iterable
在这里插入图片描述
解决:

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

闽ICP备14008679号