donglixp / coarse2fine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cannot save train.pt

shuaichenchang opened this issue · comments

Hi,
when I run preprocess.py , I got
File "preprocess.py", line 70, in <module>
main()
File "preprocess.py", line 65, in main
torch.save(train, open(os.path.join(opt.save_data, 'train.pt'), 'wb'))
File "/Users/SC/anaconda2/envs/python3/lib/python3.6/site-packages/torch/serialization.py", line 161, in save
return _with_file_like(f, "wb", lambda f: _save(obj, f, pickle_module, pickle_protocol))
File "/Users/SC/anaconda2/envs/python3/lib/python3.6/site-packages/torch/serialization.py", line 118, in _with_file_like
return body(f)
File "/Users/SC/anaconda2/envs/python3/lib/python3.6/site-packages/torch/serialization.py", line 161, in <lambda>
return _with_file_like(f, "wb", lambda f: _save(obj, f, pickle_module, pickle_protocol))
File "/Users/SC/anaconda2/envs/python3/lib/python3.6/site-packages/torch/serialization.py", line 232, in _save
pickler.dump(obj)
AttributeError: Can't pickle local object 'TableDataset.__init__.<locals>.filter_pred'

It happens when the code try to save train.pt in line 65:
torch.save(train, open(os.path.join(opt.save_data, 'train.pt'), 'wb'))
I found there is a comment in the code:# Can't save fields, so remove/reconstruct at training time. But I didn't understand how should I modify the code when training. Could you please tell me what I should do?
Thanks,

Hi @shuaichenchang ,

No modification is needed for training. Maybe you could use Python 3.5 + PyTorch 0.2.0.post3 (GPU) to run the code and try again. The detailed Python dependencies are shown in requirements.txt . Thanks!

Li

@shuaichenchang , I too am trying to run preprocess.py ; Did you come across the following error-
File "/home/coarse2fine/wikisql/table/ModelConstructor.py", line 13, in
from lib.query import agg_ops, cond_ops
I am using lib module from the WikiSQL github repository as I could not find one in current repository. Can you provide any suggestions?

Thank you,
Sandy

@Sandy26 Solved in #3

Had the same error

AttributeError: Can't pickle local object 'TableDataset.init..filter_pred'

Align these torch packages' version fixed it~
torchtext==0.2.0
torch==0.2.0.post3