<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/numpy.py#L6787-L6820) |

Pad a tensor.

#### View aliases


**Main aliases**

[`tf.keras.ops.numpy.pad`](https://www.tensorflow.org/api_docs/python/tf/keras/ops/pad)

<br />

    tf.keras.ops.pad(
        x, pad_width, mode='constant', constant_values=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | Tensor to pad. |
| `pad_width` | Number of values padded to the edges of each axis. `((before_1, after_1), ...(before_N, after_N))` unique pad widths for each axis. `((before, after),)` yields same before and after pad for each axis. `(pad,)` or `int` is a shortcut for `before = after = pad` width for all axes. |
| `mode` | One of `"constant"`, `"edge"`, `"linear_ramp"`, `"maximum"`, `"mean"`, `"median"`, `"minimum"`, `"reflect"`, `"symmetric"`, `"wrap"`, `"empty"`, `"circular"`. Defaults to `"constant"`. |
| `constant_values` | value to pad with if `mode == "constant"`. Defaults to `0`. A `ValueError` is raised if not None and `mode != "constant"`. |

<br />

<br />

<br />

<br />

| ## Note ||
|---|---|
| Torch backend only supports modes `"constant"`, `"reflect"`, `"symmetric"` and `"circular"`. Only Torch backend supports `"circular"` mode. ||

<br />

<br />

<br />

<br />

| ## Note ||
|---|---|
| Tensorflow backend only supports modes `"constant"`, `"reflect"` and `"symmetric"`. ||

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Padded tensor. ||

<br />