Source code for

from torchtext.utils import download_from_url, extract_archive
from import _RawTextIterableDataset
from import _wrap_split_argument
from import _add_docstring_header
import io

URL = ''

MD5 = '7c2ac02c03563afcf9b574c7e56c153a'

    'train': 25000,
    'test': 25000,

_PATH = 'aclImdb_v1.tar.gz'

[docs]@_add_docstring_header(num_lines=NUM_LINES, num_classes=2) @_wrap_split_argument(('train', 'test')) def IMDB(root, split): def generate_imdb_data(key, extracted_files): for fname in extracted_files: if 'urls' in fname: continue elif key in fname and ('pos' in fname or 'neg' in fname): with, encoding="utf8") as f: label = 'pos' if 'pos' in fname else 'neg' yield label, dataset_tar = download_from_url(URL, root=root, hash_value=MD5, hash_type='md5') extracted_files = extract_archive(dataset_tar) iterator = generate_imdb_data(split, extracted_files) return _RawTextIterableDataset("IMDB", NUM_LINES[split], iterator)


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources