To rescale a 2D 1-channel image the input should be 4D: batch x chan x height x width
The error message indeed is a bit unclear.
See the interpolate() 56 in the docs:
"Currently temporal, spatial and volumetric sampling are supported, i.e. expected inputs are 3-D, 4-D or 5-D in shape.
The input dimensions are interpreted in the form: mini-batch x channels x [optional depth] x [optional height] x width.
The modes available for resizing are: nearest, linear (3D-only), bilinear, bicubic (4D-only), trilinear (5D-only), area"
The following should work:
img = torch.rand(1,1,128,128)
img2 = F.interpolate(img, scale_factor=(0.5,0.5), mode="bicubic")