[2019-01-10 17:07:12,320 INFO] Building & saving training data...
[2019-01-10 17:07:12,320 INFO] Reading source and target files: data/src-train.txt data/tgt-train.txt.
[2019-01-10 17:07:12,484 INFO] Building shard 0.
[2019-01-10 17:07:12,686 INFO] * saving 0th train data shard to data/demo.train.0.pt.
Traceback (most recent call last):
File "preprocess.py", line 177, in
main()
File "preprocess.py", line 167, in main
train_dataset_files = build_save_dataset('train', fields, opt)
File "preprocess.py", line 100, in build_save_dataset
dataset.save(data_path)
File "/home/zhangliang/test/OpenNMT-py/onmt/inputters/dataset_base.py", line 96, in save
torch.save(self, path)
File "/home/zhangliang/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 218, in save
return _with_file_like(f, "wb", lambda f: _save(obj, f, pickle_module, pickle_protocol))
File "/home/zhangliang/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 143, in _with_file_like
return body(f)
File "/home/zhangliang/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 218, in
return _with_file_like(f, "wb", lambda f: _save(obj, f, pickle_module, pickle_protocol))
File "/home/zhangliang/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 291, in _save
pickler.dump(obj)
File "/home/zhangliang/test/OpenNMT-py/onmt/inputters/dataset_base.py", line 61, in reduce_ex
return super(DatasetBase, self).reduce_ex()
TypeError: reduce_ex() takes exactly one argument (0 given)
这是由于OpenNMT对于python3.7不兼容的bug引起的,在我的pc上python版本是3.5没有这个问题,但是在python3.7环境下就出现了这个问题。最后是github大佬帮助我找到了这个原因,希望高手们能投入到项目中PR一下
解决方案:退回到python3.6或3.5版本,anaconda3.4版本,不要用anaconda3.5
之后这个bug应该会被修复,到时候就可以用python3.7了
网友评论