You could set the new value using a condition on your targets:
dataset = datasets.MNIST(
root='PATH',
transform=transforms.ToTensor()
)
dataset.targets[dataset.targets > 5] = 5
print(dataset.targets.unique())
> tensor([0, 1, 2, 3, 4, 5])
You could set the new value using a condition on your targets:
dataset = datasets.MNIST(
root='PATH',
transform=transforms.ToTensor()
)
dataset.targets[dataset.targets > 5] = 5
print(dataset.targets.unique())
> tensor([0, 1, 2, 3, 4, 5])