<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#L653-L692) |

Append tensor `x2` to the end of tensor `x1`.

#### View aliases


**Main aliases**

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

<br />

    tf.keras.ops.append(
        x1, x2, axis=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x1` | First input tensor. |
| `x2` | Second input tensor. |
| `axis` | Axis along which tensor `x2` is appended to tensor `x1`. If `None`, both tensors are flattened before use. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A tensor with the values of `x2` appended to `x1`. ||

<br />

#### Examples:

    x1 = keras.ops.convert_to_tensor([1, 2, 3])
    x2 = keras.ops.convert_to_tensor([[4, 5, 6], [7, 8, 9]])
    keras.ops.append(x1, x2)
    array([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=int32)

When `axis` is specified, `x1` and `x2` must have compatible shapes.

    >>> x1 = keras.ops.convert_to_tensor([[1, 2, 3], [4, 5, 6]])
    >>> x2 = keras.ops.convert_to_tensor([[7, 8, 9]])
    >>> keras.ops.append(x1, x2, axis=0)
    array([[1, 2, 3],
            [4, 5, 6],
            [7, 8, 9]], dtype=int32)
    >>> x3 = keras.ops.convert_to_tensor([7, 8, 9])
    >>> keras.ops.append(x1, x3, axis=0)
    Traceback (most recent call last):
        ...
    TypeError: Cannot concatenate arrays with different numbers of
    dimensions: got (2, 3), (3,).