Can I rotate two dimensional images (e.g. MNIST) without having to unsqueeze each one?

It’ll work without unsqueezing the raw data if you iterate the tensors:

dataset = datasets.MNIST(root=root, download=False, transform=transforms.ToTensor())
data, target = next(iter(dataset))

test = transforms.functional.rotate(data, 90)
1 Like