I have a tensor img
in PyTorch of size bx2xhxw
and want to upsample it using torch.nn.functional.interpolate
. But while interpolation I do not wish channel 1 to use information from channel 2. To do this should I do,
img2 = torch.rand(b,2,2*h,2*w) # create a random torch tensor.
img2[:,0,:,:] = nn.functional.interpolate(img[:,0,:,:], [2*h,2*w], mode='bilinear', align_corners=True)
img2[:,1,:,:] = nn.functional.interpolate(img[:,1,:,:], [2*h,2*w], mode='bilinear', align_corners=True)
img=img2
or simply using
img = nn.functional.interpolate(img, [2*h,2*w], mode='bilinear', align_corners=True)
will solve my purpose?