pythonpytorchtorchtext

How to add modules from torchtext.data?


I'm trying to do this from torchtext.data import TabularDataset, Field, LabelField, BucketIterator, however, I get the following exception:

ImportError: cannot import name 'TabularDataset' from 'torchtext.data' (D:\Users\shuvo\miniconda3\envs\vi38\lib\site-packages\torchtext\data_init_.py)

But I see it in the documentation (figure below). Is there any other way to import it?

enter image description here


Solution

  • torchtext.data and its contents have been obsolete for a big while now (readthedocs are grossly outdated). For a time being, it's been available as torchtext.legacy.data, but it has been removed entirely in the recent versions as far as I know, in a favour of modern torchdata routines, such as torchdata.datapipes.iter.CSVParser.