interpolate#

ivy.interpolate(x, size, /, *, mode='linear', scale_factor=None, recompute_scale_factor=None, align_corners=None, antialias=False, out=None)[source]#

Down/up samples the input to the given size. The algorithm used for interpolation is determined by mode.

Parameters:
  • x (Union[Array, NativeArray]) – Input array, Must have the shape [batch x channels x [optional depth] x [optional height] x width].

  • size (Union[Sequence[int], int]) – Output size.

  • mode (Literal[‘linear’, ‘bilinear’, ‘trilinear’, ‘nearest’, ‘area’, ‘nearest_exact’, ‘tf_area’, ‘bicubic_tensorflow’, ‘bicubic’, ‘mitchellcubic’, ‘lanczos3’, ‘lanczos5’, ‘gaussian’]) – Interpolation mode. Can be one of the following: (default: 'linear') - linear - bilinear - trilinear - nearest - nearest-exact - area - tf_area - bicubic - mitchellcubic - lanczos3 - lanczos5 - gaussian

  • scale_factor (Optional[Union[int, Sequence[int]]]) – Multiplier for spatial size that defines the output size (overwriting size). (default: None)

  • align_corners (Optional[bool]) – If True, the corner pixels of the input and output tensors are aligned, (default: None) and thus preserving the values at the corner pixels. If False, the corner pixels are not aligned, and the interpolation uses edge value padding for out-of-boundary values. only has an effect when mode is ‘linear’, ‘bilinear’, ‘bicubic’ or ‘trilinear’. Default: False

  • antialias (bool) – If True, antialiasing is applied when downsampling an image. (default: False) Supported modes: ‘bilinear’, ‘bicubic’.

  • out (Optional[Array]) – Optional output array, for writing the result to. It must (default: None) have a shape that the inputs broadcast to.

Return type:

Array

Returns:

resized array

Array.interpolate(self, size, /, *, mode='linear', scale_factor=None, recompute_scale_factor=None, align_corners=None, antialias=False, out=None)#

Down/up samples the input to the given size. The algorithm used for interpolation is determined by mode.

Parameters:
  • self – Input array, Must have the shape [batch x channels x [optional depth] x [optional height] x width].

  • size (Union[Sequence[int], int]) – Output size.

  • mode (Literal[‘linear’, ‘bilinear’, ‘trilinear’, ‘nearest’, ‘area’, ‘nearest_exact’, ‘tf_area’, ‘bicubic’]) – Interpolation mode. Can be one of the following: (default: 'linear') - linear - bilinear - trilinear - nearest - area - tf_area - bicubic - mitchellcubic - lanczos3 - lanczos5 - gaussian

  • scale_factor (Optional[Union[int, Sequence[int]]]) – Multiplier for spatial size that defines the output size (default: None) (overwriting size).

  • align_corners (Optional[bool]) – If True, the corner pixels of the input and output tensors are aligned, (default: None) and thus preserving the values at the corner pixels. If False, the corner pixels are not aligned, and the interpolation uses edge value padding for out-of-boundary values. only has an effect when mode is ‘linear’, ‘bilinear’, ‘bicubic’ or ‘trilinear’. Default: False

  • antialias (bool) – If True, antialiasing is applied when downsampling an image. (default: False) Supported modes: ‘bilinear’, ‘bicubic’.

  • out (Optional[Array]) – Optional output array, for writing the result to. It must (default: None) have a shape that the inputs broadcast to.

Return type:

Array

Returns:

resized array

Container.interpolate(self, size, /, *, mode='linear', scale_factor=None, recompute_scale_factor=None, align_corners=None, antialias=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#

Down/up samples the input to the given size. The algorithm used for interpolation is determined by mode.

Parameters:
  • x – Input array, Must have the shape [batch x channels x [optional depth] x [optional height] x width].

  • size (Union[Sequence[int], int]) – Output size.

  • mode (Literal[‘linear’, ‘bilinear’, ‘trilinear’, ‘nearest’, ‘area’, ‘nearest_exact’, ‘tf_area’, ‘bicubic’]) – Interpolation mode. Can be one of the following: (default: 'linear') - linear - bilinear - trilinear - nearest - area - tf_area - bicubic - mitchellcubic - lanczos3 - lanczos5 - gaussian

  • scale_factor (Optional[Union[int, Sequence[int]]]) – Multiplier for spatial size that defines the output (default: None) size (overwriting size).

  • align_corners (Optional[bool]) – If True, the corner pixels of the input and output tensors are aligned, (default: None) and thus preserving the values at the corner pixels. If False, the corner pixels are not aligned, and the interpolation uses edge value padding for out-of-boundary values. only has an effect when mode is ‘linear’, ‘bilinear’, ‘bicubic’ or ‘trilinear’. Default: False

  • antialias (bool) – If True, antialiasing is applied when downsampling an image. (default: False) Supported modes: ‘bilinear’, ‘bicubic’.

  • out (Optional[Container]) – Optional output array, for writing the result to. It must (default: None) have a shape that the inputs broadcast to.

Return type:

Container

Returns:

resized array