# tf.keras.layers.Softmax

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v2.8.0/keras/layers/advanced_activations.py#L294-L359) |

Softmax activation function.

Inherits From: [`Layer`](https://www.tensorflow.org/versions/r2.8/api_docs/python/tf/keras/layers/Layer), [`Module`](https://www.tensorflow.org/versions/r2.8/api_docs/python/tf/Module)

#### View aliases


**Compat aliases for migration**

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

[`tf.compat.v1.keras.layers.Softmax`](https://www.tensorflow.org/api_docs/python/tf/keras/layers/Softmax)

<br />

    tf.keras.layers.Softmax(
        axis=-1, **kwargs
    )

#### Example without mask:

    inp = np.asarray([1., 2., 1.])
    layer = tf.keras.layers.Softmax()
    layer(inp).numpy()
    array([0.21194157, 0.5761169 , 0.21194157], dtype=float32)
    mask = np.asarray([True, False, True], dtype=bool)
    layer(inp, mask).numpy()
    array([0.5, 0. , 0.5], dtype=float32)

<br />

<br />

<br />

| ## Input shape ||
|---|---|
| Arbitrary. Use the keyword argument `input_shape` (tuple of integers, does not include the samples axis) when using this layer as the first layer in a model. ||

<br />

<br />

<br />

<br />

| ## Output shape ||
|---|---|
| Same shape as the input. ||

<br />

<br />

<br />

<br />

| ## Args ||
|---|---|
| `axis` | Integer, or list of Integers, axis along which the softmax normalization is applied. |

<br />

<br />

<br />

<br />

| ## Call arguments ||
|---|---|
| `inputs` | The inputs, or logits to the softmax layer. |
| `mask` | A boolean mask of the same shape as `inputs`. Defaults to `None`. The mask specifies 1 to keep and 0 to mask. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| softmaxed output with the same shape as `inputs`. ||

<br />