lizekang/ITDD

TypeError: 'generator' object is not callable

iAlexKai opened this issue · 4 comments

Python 2.7
torch 1.0.1
torch text 0.4.0

image
I try to preprocess the data, but when it save data, a TypeError occurs: 'generator' object is not callable. Can anyone help me?

Traceback (most recent call last):
File "preprocess.py", line 206, in
main()
File "preprocess.py", line 196, in main
train_dataset_files = build_save_dataset('train', fields, opt)
File "preprocess.py", line 128, in build_save_dataset
dataset.save(data_path)
File "/home1/myk/ITDD/onmt/inputters/dataset_base.py", line 75, in save
torch.save(self, path)
File "/home1/myk/env/local/lib/python2.7/site-packages/torch/serialization.py", line 219, i
n save
return _with_file_like(f, "wb", lambda f: _save(obj, f, pickle_module, pickle_protocol))
File "/home1/myk/env/local/lib/python2.7/site-packages/torch/serialization.py", line 144, i
n _with_file_like
return body(f)
File "/home1/myk/env/local/lib/python2.7/site-packages/torch/serialization.py", line 219, i
n
return _with_file_like(f, "wb", lambda f: _save(obj, f, pickle_module, pickle_protocol))
File "/home1/myk/env/local/lib/python2.7/site-packages/torch/serialization.py", line 292, i
n _save
pickler.dump(obj)
TypeError: 'generator' object is not callable

I change knl_seq_length_trunc to 200, and get the same error

Please use python>=3.6.

Thanks. I change python to 3.6.5, and I meet with another error:ValueError: max() arg is an empty sequence
Traceback (most recent call last):
File "train.py", line 120, in
main(opt)
File "train.py", line 51, in main
single_main(opt, 0)
File "/home1/myk/ITDD/onmt/train_single.py", line 160, in main
opt.valid_steps)
File "/home1/myk/ITDD/onmt/trainer.py", line 146, in train
for i, batch in enumerate(train_iter):
File "/home1/myk/ITDD/onmt/inputters/inputter.py", line 506, in iter
for batch in self.cur_iter:
File "/home1/myk/p3.6/lib/python3.6/site-packages/torchtext/data/iterator.py", line 157, in iter
yield Batch(minibatch, self.dataset, self.device)
File "/home1/myk/p3.6/lib/python3.6/site-packages/torchtext/data/batch.py", line 34, in init
setattr(self, name, field.process(batch, device=device))
File "/home1/myk/p3.6/lib/python3.6/site-packages/torchtext/data/field.py", line 200, in process
padded = self.pad(batch)
File "/home1/myk/p3.6/lib/python3.6/site-packages/torchtext/data/field.py", line 218, in pad
max_len = max(len(x) for x in minibatch)
ValueError: max() arg is an empty sequence

image

OK。
added this modify to the inputter.py and it workes.
if len(b) == 0: continue

image