AttributeError: 'Variable' object has no attribute 'creator'

when I run this code,I want to see the creator attribute of y,while gives me an error of: AttributeError: ‘Variable’ object has no attribute 'creator’
how to resolve it?

import torch
from torch.autograd import Variable

x = Variable(torch.ones(2, 2), requires_grad=True)
y = x + 2
print(y)
print(y.creator)

3 Likes

I think .creator was replaced with .grad_fn in May as can be seen here: https://github.com/pytorch/tutorials/pull/91/files

6 Likes

thanks for your answer:relaxed: