resize

dragon.vision.resize(
  inputs,
  sizes=None,
  scales=None,
  mode='linear',
  align_corners=False,
  data_format='NCHW',
  **kwargs
)[source]

Resize input via interpolating neighborhoods.

sizes or scales will be selected by data_format:

x, sizes = dragon.ones((1, 2, 3, 4)), (6, 6)
a = dragon.vision.resize(x, sizes, data_format='NCHW')  # Shape: (1, 2, 6, 6)
c = dragon.vision.resize(x, sizes, data_format='NHWC')  # Shape: (1, 6, 6, 4)

Set align_corners to determine the input coordinates in linear mode:

# align_corners = False
# Use half-pixel transformation
scale = float(in_size) / float(out_size)
in_coord = (out_coord + 0.5) * scale - 0.5

# align_corners = True
# Use align-corners transformation
scale = float(in_size - 1) / float(out_size - 1)
in_coord = out_coord * scale
Parameters:
  • inputs (dragon.Tensor) – The input tensor.
  • sizes (Union[int, Sequence[int], dragon.Tensor], optional) – The output dimensions.
  • scales (Union[float, Sequence[float], dragon.Tensor], optional) – The scale along each input dimension.
  • mode ({'nearest', 'linear'}, optional) – The interpolation mode.
  • align_corners (bool, optional, default=False) – Whether to align corners in linear interpolating.
  • data_format ({'NCHW', 'NHWC'}, optional) – The optional data format.
Returns:

dragon.Tensor – The output tensor.