Hello,
I am working on a project that uses a tensor of dimensions [features x width x height]. The features vector has size 2, representing the x and y physical displacements of a certain mechanical engineering experiment. I wanted to augment my data by rotating my samples, however the same approach as used to rotate images can’t be used, as the channels of a colour image don’t change when you move them in space, but my (x,y) channels have to change to align with my new rotation of the sample.
I know how to do this rotation “element wise”, as in, iterating through every spatial (width x height) coordinate of the tensor and applying a rotation matrix on the (x,y) features to get the new correct orientation for that point in the displacement field based on how much I rotated the sample. I would think, however, that there must be a more efficient way to do this transform. So I have 2 questions:
-
Is there a pytorch or numpy function or module that would help me apply the rotation to the entire displacement field at once?
-
If there isn’t, would it be better to build a matrix to do this rotation on the entire field or apply a
for
loop on all elements? And if the matrix rotation is more efficient, which I’m pretty sure it is, how would I go about building that matrix for the entire field?