Thanks for your reply.
Yeah, storing the angles in a list would do the trick. I’m afraid this solution (overriding __getitem__) is not efficient though.
Do you have ideas of how I could rotate the input and save the corresponding target beforehand?
So that I could combine this pre-processing with other transforms.
For context, this is my current piece of code:
class RotatedMNIST(MNIST):
  def __getitem__(self, i):
    input, target = super(RotatedMNIST, self).__getitem__(i)
    target = random.normalvariate(0, 3.14/4)
    input = TF.rotate(input, target * (180 / 3.14))
    input = transforms.ToTensor()(input)
    return input, target

trainloader = DataLoader(RotatedMNIST('./data', train=True, download=True), batch_size=batch_size, shuffle=True)