How to repeat tensor in a specific new dimension in PyTorch
tensor.repeat should suit your needs but you need to insert a unitary dimension first. For this we could use either tensor.unsqueeze or tensor.reshape. Since unsqueeze is specifically defined to insert a unitary dimension we will use that. B = A.unsqueeze(1).repeat(1, K, 1) Code Description A.unsqueeze(1) turns A from an [M, N] to [M, 1, N] … Read more