question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load vocab objects - _default_unk_index issue

See original GitHub issue

Exception: 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
QDxiaoyecommented, Oct 31, 2019

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

2reactions
duhaimecommented, Jun 11, 2020

I just downgraded to 0.3.1 and this issue was resolved:

pip install torchtext==0.3.1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't get attribute '_default_unk_index' on <module 'torchtext ...
Scenario 1. vocab saved with torchtext 0.3.1. vocab loaded using torchtext 0.4.0. Solution is, downgrade torchtext from ...
Read more >
Vocab · spaCy API Documentation
The Vocab object provides a lookup table that allows you to access Lexeme objects, as well as the StringStore . It also owns...
Read more >
Custom vocabularies - Amazon Transcribe
Once your custom vocabulary is ready to use, log into the AWS Management Console, select Real-time transcription, scroll to Customizations, toggle on Custom ......
Read more >
Vocabulary - Department of Education and Training Victoria
story retelling using key vocabulary from texts; use of props or concrete objects to explain vocabulary; explicit discussion of comprehension ...
Read more >
Stop Front-Loading Vocabulary In Science - iExploreScience
never understanding. The Traditional Strategies That Are Failing You. The timing of our vocabulary instruction is not the only problem, of course. Our ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found