@Hmrishav_Bandyopadhy If you want to do an affine transformation, then you can use code similar to what ptrblck shows above, but instead of using linspace/meshgrid to produce the grid, use F.affine_grid() 49.
You just have to pass it a matrix theta which contains the affine parameters for your transformation.
Then pass the resulting grid to grid_sample.
For upsampling/downsampling specifically, I wouldn’t recommend using grid_sample (although, of course, you could if you really wanted to). For this, you should probably use F.interpolate() 36, which is specifically for upsampling and downsampling.
If you’re wondering about the range of coordinates in the grid passed to grid sample, they range from -1 to 1, where -1 refers to either the top or left edges of the sampled image (in the x and y axes, respectively), while +1 refers to the bottom or right edges of the sampled image. So a grid point containing (0, 0), for example, would sample from the center of the image.