I’m loading the MNIST dataset using torchvision like this:
train_loader = torch.utils.data.DataLoader(
torchvision.datasets.MNIST(’/home/achennault/research/mnist/’, train=True, download=True,
transform=torchvision.transforms.Compose([
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize(
(0.1307,), (0.3081,))
])),
batch_size=batch_size_train, shuffle=True, drop_last = True)
test_loader = torch.utils.data.DataLoader(
torchvision.datasets.MNIST(’/home/achennault/research/mnist/’, train=False, download=True,
transform=torchvision.transforms.Compose([
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize(
(0.1307,), (0.3081,))
])),
batch_size=batch_size_test, shuffle=True, drop_last = True)
I have a list of indices of train_loader.dataset containing elements I want to keep. I want to selecct only these elements of the DataSet, then use the restricted DataSet in the DataLoader. Is there any way to do this?