mdtux89 / amr-eager

Parser for Abstract Meaning Representation
BSD 2-Clause "Simplified" License
45 stars 19 forks source link

UnpicklingError while loading the model with PyTorch #4

Open The-Gupta opened 6 years ago

The-Gupta commented 6 years ago

`import torch import torch.autograd import torch.nn import torch.multiprocessing import torch.utils import torch.legacy.nn import torch.legacy.optim

xp = torch.load(r"D:\SDS\1_MachineLearning\amr-eager-master\LDC2015E86\reentrancies.dat")`

Traceback (most recent call last):

File "", line 9, in xp = torch.load(r"D:\SDS\1_MachineLearning\amr-eager-master\LDC2015E86\reentrancies.dat")

File "D:\Anaconda3\envs\amr-eager\lib\site-packages\torch\serialization.py", line 261, in load return _load(f, map_location, pickle_module)

File "D:\Anaconda3\envs\amr-eager\lib\site-packages\torch\serialization.py", line 399, in _load magic_number = pickle_module.load(f)

UnpicklingError: invalid load key, ''.

reentrancies.dat model weights could be downloaded from here. What should I change?

The-Gupta commented 6 years ago

@tastyminerals, could you help me with this?

tastyminerals commented 6 years ago

torch.load works with torch models, they have .t7 extension. You are loading a .dat file. This does not look like a torch model.

@mdtux89 is correct. Yep, only now noticed, you are using python. This is a Torch repo not PyTorch. These are two separate frameworks, Torch uses Lua, PyTorch uses Python. You need to convert this model to PyTorch first. Please read this: https://discuss.pytorch.org/t/convert-import-torch-model-to-pytorch/37/2 and this: https://github.com/clcarwin/convert_torch_to_pytorch

mdtux89 commented 6 years ago

It is a Lua Torch model, not pytorch

The-Gupta commented 6 years ago

require 'dp' require 'optim' require 'nngraph' xp = torch.load(r"D:/SDS/1_MachineLearning/amr-eager-master/LDC2015E86/labels.dat")

Loads with LuaJIT on Linux.

@mdtux89, okay, now I know I can't use this model directly in Python. I had visited the links suggested by @tastyminerals, but could not understand how to convert the model. Could you convert or suggest how to?

mdtux89 commented 6 years ago

https://discuss.pytorch.org/t/convert-import-torch-model-to-pytorch/37/2 I am out of office and as I said before via email I am not able to provide you with support on this at the moment