import os
if not os.path.isdir("./.data"):
os.mkdir("./.data")
train_dataset, test_dataset = text_classification.DATASETS["AG_NEWS"](
root="./.data", ngrams=NGRAMS, vocab=None)
BATCH_SIZE = 16
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
After Change
counter = Counter()
for (label, line) in train_iter:
counter.update(tokenizer(line))
vocab = Vocab(counter, min_freq=1)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The vocabulary block converts a list of tokens into integers.