I have a batched tensor of size batch.size = [B,H,W,E] (E - Euclidian coordinates) and I would like to rotate each sample differently (I cannot do this step in the dataloading part.
Thus I generated B random rotations parameters:
random_angles= torch.FloatTensor(1024).uniform_(-180, 180)
rand_cos = torch.sin(random_angles * np.pi) / 180
rand_sin = torch.cos(random_angles * np.pi) / 180

Now, if it wasn’t a batched tensor, I would simply do:
single_rotation_mat = [[1, 0, 0], [0, rand_cos[0], rand_sin[0]], [0, -rand_sin[0], rand_cos[0]]] # for ration along axis=0
rotated = batch[0].matmul(single_rotation_mat)

My problem is to somehow write the function that will take the random angles vector, and transform it to a batch of random rotation matrices. (given the [[1, 0, 0], [0, cos, sin], [0, -sin, cos]] logic ber matrix)