Here is a sample code snippet that you could use as a starter:
class CifarDataset(torch.utils.data.Dataset):
def __init__(self, root_dir):
"""Initializes a dataset containing images and labels."""
super().__init__()
raise NotImplementedError
def __len__(self):
"""Returns the size of the dataset."""
raise NotImplementedError
def __getitem__(self, index):
"""Returns the index-th data item of the dataset."""
raise NotImplementedError
train_dataset = CifarDataset(TRAIN_DIRECTORY_PATH)
train_dataloader = torch.utils.data.DataLoader(train_dataset,
batch_size=BATCH_SIZE,
shuffle=True)