I have two tensors of shape 16 X 1 X 300 and 16 X 9 X 300. 16 here is actually the batch size. I want to use torch.bmm but I need to convert 16 X 1 X 300 to 16 X 300 X 1. I want to get final result as 16 X 9 X 1.
I can do that in this way - X.squeeze(1).unsqueeze(2) but I am just wondering whether this is the right way to do this? Can anyone suggest anything better?
One more question, if I want to swap two columns of a tensor, how can I do that? For example, I want to convert 16 X 9 X 300 tensor to 16 X 300 X 9 tensor. Its actually transposing a matrix. But here I have a 3d tensor. I guess I can do that using torch.transpose() 5. Is that correct?