I want to load MNIST dataset in PyTorch and Torchvision, dividing it into train, validation and test parts. So far I have:
def load_dataset():
train_loader = torch.utils.data.DataLoader(
torchvision.datasets.MNIST(
'/data/', train=True, download=True,
transform=torchvision.transforms.Compose([
torchvision.transforms.ToTensor()])),
batch_size=batch_size_train, shuffle=True)
test_loader = torch.utils.data.DataLoader(
torchvision.datasets.MNIST(
'/data/', train=False, download=True,
transform=torchvision.transforms.Compose([
torchvision.transforms.ToTensor()])),
batch_size=batch_size_test, shuffle=True)
How can I divide the training dataset into training and validation if it's in the DataLoader
? I want to use last 10000 examples from the training dataset as a validation dataset (I know that I should do CV for more accurate results, I just want a quick validation here).