OpenNMT Forum

AttributeError: Can't get attribute 'TextDataset'

Hi, I am a user of OpenNMT-py.
I recently merged the updated git codes and encountered an attribute error, as written below. (Before, I had no problem using it)

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 “/PATH/OpenNMT-py/onmt/train_single.py”, line 160, in main
valid_steps=opt.valid_steps)
File “/PATH/OpenNMT-py/onmt/trainer.py”, line 189, in train
self._accum_batches(train_iter)):
File “/PATH/OpenNMT-py/onmt/trainer.py”, line 124, in _accum_batches
for batch in iterator:
File “/PATH/OpenNMT-py/onmt/inputters/inputter.py”, line 561, in iter
for batch in self._iter_dataset(path):
File “/PATH/OpenNMT-py/onmt/inputters/inputter.py”, line 531, in _iter_dataset
cur_dataset = torch.load(path)
File “/PATH’/.conda/envs/NAME/lib/python3.7/site-packages/torch/serialization.py”, line 367, in load
return _load(f, map_location, pickle_module)
File “/PATH’/.conda/envs/NAME/lib/python3.7/site-packages/torch/serialization.py”, line 538, in _load
result = unpickler.load()
AttributeError: Can’t get attribute ‘TextDataset’ on <module ‘onmt.inputters.text_dataset’ from ‘/PATH/OpenNMT-py/onmt/inputters/text_dataset.py’>

I am very confused, since I did not change anything from the code.
Also, when I search for ‘TextDataset’, I found only [docs/source/onmt.io.rst] contains it.
Is this something to do with the .rst file?

I would appreciate any help from you.
P.S. I’m using pytorch 1.0.0 and torchtext 0.4.0.

you need to re preprocess your data.

we’ve mentioned this in the last release.