mlx.core.pad

目錄

mlx.core.pad#

pad(a: array, pad_width: int | tuple[int] | tuple[int, int] | list[tuple[int, int]], mode: Literal['constant', 'edge', 'reflect', 'symmetric'] = 'constant', constant_values: scalar | array = 0, *, stream: StreamOrDevice = None) → array#

Pad an array with a constant value

參數:
  • a (array) -- 輸入陣列。

  • pad_width (int, tuple(int), tuple(int, int) or list(tuple(int, int))) -- Number of padded values to add to the edges of each axis:((before_1, after_1), (before_2, after_2), ..., (before_N, after_N)). If a single pair of integers is passed then (before_i, after_i) are all the same. If a single integer or tuple with a single integer is passed then all axes are extended by the same number on each side.

  • mode -- Padding mode. One of the following strings: "constant" (default): Pads with a constant value. "edge": Pads with the edge values of array. "reflect": Pads with the reflection of the array, without repeating the edge values. "symmetric": Pads with the reflection of the array, repeating the edge values.

  • constant_values (array or scalar, optional) -- Optional constant value to pad the edges of the array with.

回傳值:

The padded array.

回傳值型別:

array