Search code examples
pythonpytorchdataloader

Checking the contents of python dataloader


This is probably a simple question, but how see how the contents of this standard data loader looks like:

from torchtext import datasets
import random

train_data, test_data = datasets.IMDB.splits(TEXT, LABEL)
train_data, valid_data = train_data.split(random_state = random.seed(SEED))

I can't use .head() and:

print(test_data)

just gives me:

<torchtext.datasets.imdb.IMDB object at 0x7f0b42e8c240>

I'm probably just missing .values or [0] or something similar...


Solution

  • Datasets are iterables, you can get the first element with next(iter(test_data)).