问题:AttributeError: 'Tensor' object has no attribute 'creator'
生活随笔
收集整理的這篇文章主要介紹了
问题:AttributeError: 'Tensor' object has no attribute 'creator'
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
AttributeError: 'Tensor' object has no attribute 'creator'
?
根據pytorch官方文檔的說法,變量具有如上的三個屬性,在獲取y操作的creator屬性時,卻出現沒有該屬性的錯誤。
import torch from torch.autograd import Variable x = Variable(torch.ones(1,3), requires_grad=True) y = x+2 print('x: ', x) print('y: ', y) print(y.creator)?經查,發現creator屬性名稱已經改為grad_fn,很多文檔還未進行修改
github上修改提交:https://github.com/pytorch/tutorials/pull/91/files
修改之后,再次運行,即可獲取y的已創建Function屬性的屬性Variable
import torch from torch.autograd import Variable x = Variable(torch.ones(1,3), requires_grad=True) y = x+2 print('x: ', x) print('y: ', y) print(y.grad_fn)總結
以上是生活随笔為你收集整理的问题:AttributeError: 'Tensor' object has no attribute 'creator'的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows10安装TeXlive和T
- 下一篇: pytorch查看应用指数衰减后的学习率