<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/linalg.py#L340-L399) |

Matrix or vector norm.

#### View aliases


**Main aliases**

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

<br />

    tf.keras.ops.norm(
        x, ord=None, axis=None, keepdims=False
    )

This function is able to return one of eight different matrix norms, or one
of an infinite number of vector norms (described below), depending on the
value of the `ord` parameter.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | Input tensor. |
| `ord` | Order of the norm (see table under Notes). The default is `None`. |
| `axis` | If `axis` is an integer, it specifies the axis of `x` along which to compute the vector norms. If `axis` is a 2-tuple, it specifies the axes that hold 2-D matrices, and the matrix norms of these matrices are computed. |
| `keepdims` | If this is set to `True`, the axes which are reduced are left in the result as dimensions with size one. |

<br />

<br />

<br />

| ## Note ||
|---|---|
| For values of `ord < 1`, the result is, strictly speaking, not a mathematical 'norm', but it may still be useful for various numerical purposes. The following norms can be calculated: <br /> - For matrices: - `ord=None`: Frobenius norm - `ord="fro"`: Frobenius norm - `ord="nuc"`: nuclear norm - `ord=np.inf`: `max(sum(abs(x), axis=1))` - `ord=-np.inf`: `min(sum(abs(x), axis=1))` - `ord=0`: not supported - `ord=1`: `max(sum(abs(x), axis=0))` - `ord=-1`: `min(sum(abs(x), axis=0))` - `ord=2`: 2-norm (largest sing. value) - `ord=-2`: smallest singular value - other: not supported - For vectors: - `ord=None`: 2-norm - `ord="fro"`: not supported - `ord="nuc"`: not supported - `ord=np.inf`: `max(abs(x))` - `ord=-np.inf`: `min(abs(x))` - `ord=0`: `sum(x != 0)` - `ord=1`: as below - `ord=-1`: as below - `ord=2`: as below - `ord=-2`: as below - other: `sum(abs(x)**ord)**(1./ord)` ||

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Norm of the matrix or vector(s). ||

<br />

#### Example:

    x = keras.ops.reshape(keras.ops.arange(9, dtype="float32") - 4, (3, 3))
    keras.ops.linalg.norm(x)
    7.7459664