Unable to load vocab objects - _default_unk_index issue
See original GitHub issueException:
Error while loading vocabularies: Can't get attribute '_default_unk_index' on <module 'torchtext.vocab' from 'home/user/project/env37/lib/python3.7/site-packages/torchtext/vocab.py'>
I have trained an encoder-decoder model for translation. For the model I have pickled the vocabularies. Now, every time I launch the program, this problem occurs. So I have to reload and process the files, then recreate the objects, in order to use my model to translate from terminal or from a file.
To pickle the vocab
objects I use the dill
module. I load the vocabularies for the source and target language as follows:
SRC_vocab = torch.load(os.path.join(path_to_exp, "src.pkl"))
,
TRG_vocab = torch.load(os.path.join(path_to_exp, "trg.pkl"))
The problem occurs with python3.7, while with python3.6 it works fine.
Attached the dependencies file (python3.7: req_37.txt, python3.6: req_36.txt). req_36.txt req_37.txt
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top GitHub Comments
I guess the issue is the version of the package. when I use dill to save object at torchtext=0.3.1 and load object at torchtext=0.4.0, the issue happend
I just downgraded to 0.3.1 and this issue was resolved: