Torchvision.transfors: How to perform identical transform on both image and target?

Do you mean the index in __getitem__?
You can pass the index directly to your Dataset:

data, target = dataset[0]

or the sampler will do it for you, if you are using a DataLoader.

1 Like