Rotating tensor inside model

I need in my model layer that rotates a tensor depending on input data and it has to rotate each sample in batch differently, torch.rot90 doesn’t work on batches, so how this should be done?

If you want to rotate only some slices, you might want to index these particular slices of the input tensor, rotate them, and recreate the tensor afterwards using e.g. torch.cat.

1 Like