问题:AttributeError: 'Tensor' object has no attribute 'creator'
生活随笔
收集整理的這篇文章主要介紹了
问题:AttributeError: 'Tensor' object has no attribute 'creator'
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
AttributeError: 'Tensor' object has no attribute 'creator'
?
根據(jù)pytorch官方文檔的說法,變量具有如上的三個(gè)屬性,在獲取y操作的creator屬性時(shí),卻出現(xiàn)沒有該屬性的錯(cuò)誤。
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)?經(jīng)查,發(fā)現(xiàn)creator屬性名稱已經(jīng)改為grad_fn,很多文檔還未進(jìn)行修改
github上修改提交:https://github.com/pytorch/tutorials/pull/91/files
修改之后,再次運(yùn)行,即可獲取y的已創(chuàng)建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)總結(jié)
以上是生活随笔為你收集整理的问题:AttributeError: 'Tensor' object has no attribute 'creator'的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows10安装TeXlive和T
- 下一篇: pytorch查看应用指数衰减后的学习率