resize

hybrid_learning.datasets.transforms.image_transforms.resize(tens, size, mode='bilinear')[source]

Resize the given tensor assuming it to be a 2D image or batch thereof. This is a wrapper around torch.nn.functional.interpolate() which takes care of automatic unsqueezing and squeezing of batch and channel dimensions assuming 2D images.

Parameters
  • tens (Tensor) – the tensor holding a 2D image or batch thereof; dimensions are interpreted as ([[batch,] channel,] height, width)

  • size (Tuple[int, int]) – the new 2D size

  • mode (str) – the interpolation mode; one of the options for torch.nn.functional.interpolate()

Returns

tensor representing resized 2D image (batch)

Return type

Tensor