This might be because rotate expects inputs to have at least 3 dimensions and the mask just has two. Can you try mask = torch.unsqueeze(mask, 0) to add a dummy “color” dimension to the mask before rotating it?