<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/losses/losses.py#L1791-L1825) |

Computes the mean absolute error between labels and predictions.

#### View aliases


**Main aliases**

[`tf.keras.losses.mae`](https://www.tensorflow.org/api_docs/python/tf/keras/losses/MAE), [`tf.keras.metrics.MAE`](https://www.tensorflow.org/api_docs/python/tf/keras/losses/MAE), [`tf.keras.metrics.mae`](https://www.tensorflow.org/api_docs/python/tf/keras/losses/MAE)

<br />

    tf.keras.losses.MAE(
        y_true, y_pred
    )

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Intro to Autoencoders](https://www.tensorflow.org/tutorials/generative/autoencoder) |

    loss = mean(abs(y_true - y_pred), axis=-1)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `y_true` | Ground truth values with shape = `[batch_size, d0, .. dN]`. |
| `y_pred` | The predicted values with shape = `[batch_size, d0, .. dN]`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Mean absolute error values with shape = `[batch_size, d0, .. dN-1]`. ||

<br />

#### Example:

    y_true = np.random.randint(0, 2, size=(2, 3))
    y_pred = np.random.random(size=(2, 3))
    loss = keras.losses.mean_absolute_error(y_true, y_pred)