当前位置:   article > 正文

PyTorch奇奇怪怪的问题(一)_().detach().requires_grad_(true), rather than torc

().detach().requires_grad_(true), rather than torch.tensor(sourcetensor)

报错:

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).
  target = torch.tensor(target, dtype=torch.long)
  • 1
  • 2

报错语句

target = torch.tensor(target, dtype=torch.long)
  • 1

修改为

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

闽ICP备14008679号