# tf.keras.layers.average

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v2.13.1/keras/layers/merging/average.py#L61-L94) |

Functional interface to the [`tf.keras.layers.Average`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/layers/Average) layer.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

\`tf.compat.v1.keras.layers.average\`

<br />

    tf.keras.layers.average(
        inputs, **kwargs
    )

#### Example:

    x1 = np.ones((2, 2))
    x2 = np.zeros((2, 2))
    y = tf.keras.layers.Average()([x1, x2])
    y.numpy().tolist()
    [[0.5, 0.5], [0.5, 0.5]]

Usage in a functional model:

    input1 = tf.keras.layers.Input(shape=(16,))
    x1 = tf.keras.layers.Dense(8, activation='relu')(input1)
    input2 = tf.keras.layers.Input(shape=(32,))
    x2 = tf.keras.layers.Dense(8, activation='relu')(input2)
    avg = tf.keras.layers.Average()([x1, x2])
    out = tf.keras.layers.Dense(4)(avg)
    model = tf.keras.models.Model(inputs=[input1, input2], outputs=out)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `inputs` | A list of input tensors. |
| `**kwargs` | Standard layer keyword arguments. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A tensor, the average of the inputs. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If there is a shape mismatch between the inputs and the shapes cannot be broadcasted to match. |

<br />