Problem: attributeerror: ‘tensor’ object has no attribute ‘creator’

AttributeError: ‘Tensor’ object has no attribute ‘creator’

according to the official pytorch documentation, the variable has the above three properties, but the error of not having this property appears when the creator property of the y operation is obtained.

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)

after checking, it is found that the name of creator property has been changed to grad_fn, and many documents have not been modified

on making commits: https://github.com/pytorch/tutorials/pull/91/files

after modification, run again, you can get the property Variable

of the created Function property of y

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)


Read More: