interpolate#

ivy.interpolate(x, size, /, *, mode='linear', scale_factor=None, recompute_scale_factor=None, align_corners=False, 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', 'nd', 'nearest', 'area', 'nearest_exact', 'tf_area', 'tf_bicubic', 'bicubic', 'mitchellcubic', 'lanczos3', 'lanczos5', 'gaussian'], default: 'linear') – Interpolation mode. Can be one of the following: - linear - bilinear - trilinear - nd - nearest - nearest-exact - area - tf_area - bicubic - tf_bicubic - mitchellcubic - lanczos3 - lanczos5 - gaussian

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

  • recompute_scale_factor (Optional[bool], default: None) – If True, then scale_factor must be provided and scale_factor is used to compute the output size. The computed output size will be used to infer new scales for the interpolation. If recompute_scale_factor is False, then size or scale_factor will be used directly for interpolation.

  • align_corners (bool, default: False) – If True, the corner pixels of the input and output tensors are aligned, 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.

  • out (Optional[Array], default: None) – Optional output array, for writing the result to. It must 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)[source]#

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'], default: 'linear') – Interpolation mode. Can be one of the following: - linear - bilinear - trilinear - nearest - area - tf_area - bicubic - mitchellcubic - lanczos3 - lanczos5 - gaussian

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

  • align_corners (Optional[bool], default: None) – If True, the corner pixels of the input and output tensors are aligned, 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, default: False) – If True, antialiasing is applied when downsampling an image. Supported modes: ‘bilinear’, ‘bicubic’.

  • out (Optional[Array], default: None) – Optional output array, for writing the result to. It must 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)[source]#

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, Container]) – Output size.

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

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

  • align_corners (Optional[Union[bool, Container]], default: None) – If True, the corner pixels of the input and output tensors are aligned, 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 (Union[bool, Container], default: False) – If True, antialiasing is applied when downsampling an image. Supported modes: ‘bilinear’, ‘bicubic’.

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

Return type:

Container

Returns:

resized array