''Vocab' object has no attribute 'itos'

I am building ML models for NLP with pytorch, but as I define vocabulary for tekenized words in my text with "vacab" and try to use vocab.itos I get: 'Vocab' object has no attribute 'itos' error.

This is my vocab:

vocab = torchtext.vocab.vocab(counter, min_freq=1)

How can I solve this problem?



Solution 1:[1]

You should access torchtext.vocab.Vocab.get_itos to get the indices->tokens mapping.

>>> itos = vocab.get_itos()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ivan