Hello, I have a tensor with size of BxCxHxW. I want to obtain the new tensor with size of Bx3xCxHxW, How can I do it? I have used unsqueeze(1) function but it only provides Bx1xCxHxW. Thanks
This should do it then to create a tensor of same type and on the same device as A.
You can change the dtype and device arguments if you need a different type and/or device.
size = list(A.size())
size.insert(1, 3)
B = torch.zeros(size, dtype=A.dtype, device=A.device)