thnets
thnets copied to clipboard
AttributeError: creator
hello, When I try sample code (in README) to export PyTorch model, like
out = net.forward(torch.autograd.Variable(torch.FloatTensor(1,3,227,227)))
thexport.save('pymodel.net', out)
I got the following error.
File "...... /python3.6/site-packages/torch/autograd/variable.py", line 63, in __getattr__
raise AttributeError(name)
AttributeError: creator
This is a pytorch issue and has nothing to do with thnets. I have now installed the latest pytorch to see if there are any changes in syntax, but those commands work to me without any issues. Do you have maybe some (very) old version of pytorch?
I dump all that I tried:
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> from torchvision import models
>>> import thexport
>>>
>>> net = models.alexnet().eval()
>>> out = net.forward(torch.autograd.Variable(torch.FloatTensor(1,3,227,227)))
>>> thexport.save('pymodel.net', out)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/polphit/work/thnets/thexport.py", line 104, in save
e.write(output.creator)
File "/home/polphit/anaconda3/lib/python3.6/site-packages/torch/autograd/variable.py", line 63, in __getattr__
raise AttributeError(name)
AttributeError: creator
my pytorch version is
>>> torch.__version__
'0.1.12+d1a4467'
I'll try this on another machine. Thank you.
Hello, it worked perfectly on pytorch 0.1.11, but I got this issue on 0.1.12. I tested on 0.1.12 + Python 3.6.0 Anaconda: had the issue 0.1.11 + Python 3.6.0 Anaconda: worked! 0.1.12 + Python 3.5.0 (no Anaconda): had the issue 0.1.11 + Python 3.5.0 (no Anaconda): worked!
Thank you. (Surely I pulled pytorch from master branch).
I have tested it on 0.1.12_2 with Python 3.5. I don' t have Python 3.6. Maybe PyTorch has some issues with Python 3.6, I don't know.
Thank you. I guess, it may be related to 'https://discuss.pytorch.org/t/variable-no-attribute-creator/2866', which says pytorch 0.1.12 refactored autograd.
Yes, but I am using 0.1.12. The latest version downloaded today!
It seems pytorch refactored from 'creator' to 'grad_fn'. There's a pull request on the tutorial repository updating this.