Bug in pytorch neural networks tutorial

In this neural networks tutorial
http://pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html#sphx-glr-
beginner-blitz-neural-networks-tutorial-py

I got an error in here:

print(loss.grad_fn)  # MSELoss
print(loss.grad_fn.next_functions[0][0])  # Linear
print(loss.grad_fn.next_functions[0][0].next_functions[0][0])  # ReLU

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-30-95cc2826ff61> in <module>()
----> 1 print(loss.grad_fn)  # MSELoss
      2 print(loss.grad_fn.next_functions[0][0])  # Linear
      3 print(loss.grad_fn.next_functions[0][0].next_functions[0][0])  # ReLU

/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.pyc in __getattr__(self, name)
     61         if name in self._fallthrough_methods:
     62             return getattr(self.data, name)
---> 63         raise AttributeError(name)
     64 
     65     def __getitem__(self, key):

AttributeError: grad_fn

Please see my comment here. Latest pytorch renames creator to grad_fn.

I suggest before immediately “reporting a bug” at least search in github issues first!

Sorry. I searched the github issues of pytorch but not tutorial.
Thank you all for the replies.

same above code is giving error.please help!

Download notebook again, you shouldn’t get error anymore. I ‘fixed’ it.

Hi, I read the complete post but still i find error when using x.grad_fn. I am working in python. Here is first python code and then error message.

import torch
from torch.autograd import Variable
x = Variable(torch.ones(2, 2), requires_grad=True)
print(x.grad)
print(x.grad_fn)

/home/yonatan/anaconda3/envs/hello_pytorch/bin/python /home/yonatan/PycharmProjects/pytorch_tutorial/hello.py
Traceback (most recent call last):
  File "/home/yonatan/PycharmProjects/pytorch_tutorial/hello.py", line 5, in <module>
    print(x.grad_fn)
  File "/home/yonatan/anaconda3/envs/hello_pytorch/lib/python3.5/site-packages/torch/autograd/variable.py", line 63, in __getattr__
    raise AttributeError(name)
AttributeError: grad_fn
None

Process finished with exit code 1

Please look into this and suggest some solution.
Best

Are you using pytorch v0.2?

it is 0.1.2. I have installed it from within pycharm.

You should upgrade your version of PyTorch.

Hi, I updated the version of pytorch and it works now. Thanks to all.