<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/layers/activations/softmax.py#L14-L115) |

Softmax activation layer.

Inherits From: [`Layer`](https://www.tensorflow.org/api_docs/python/tf/keras/Layer), [`Operation`](https://www.tensorflow.org/api_docs/python/tf/keras/Operation)

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

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Basic classification: Classify images of clothing](https://www.tensorflow.org/tutorials/keras/classification) - [TensorFlow 2 quickstart for beginners](https://www.tensorflow.org/tutorials/quickstart/beginner) - [Building Your Own Federated Learning Algorithm](https://www.tensorflow.org/federated/tutorials/building_your_own_federated_learning_algorithm) - [Composing Learning Algorithms](https://www.tensorflow.org/federated/tutorials/composing_learning_algorithms) - [Federated Learning for Image Classification](https://www.tensorflow.org/federated/tutorials/federated_learning_for_image_classification) |

#### Formula:

    exp_x = exp(x - max(x))
    f(x) = exp_x / sum(exp_x)

#### Example:

    softmax_layer = keras.layers.Softmax()
    input = np.array([1.0, 2.0, 1.0])
    result = softmax_layer(input)
    result
    [0.21194157, 0.5761169, 0.21194157]

<br />

<br />

<br />

| ## Args ||
|---|---|
| `axis` | Integer, or list of Integers, axis along which the softmax normalization is applied. |
| `**kwargs` | Base layer keyword arguments, such as `name` and `dtype`. |

<br />

<br />

<br />

<br />

| ## Call arguments ||
|---|---|
| `inputs` | The inputs (logits) to the softmax layer. |
| `mask` | A boolean mask that is broadcastable to `inputs`. The mask specifies 1 to keep and 0 to mask. Each dimension of the mask must either be 1 or match the corresponding dimension of `inputs`; it must not be larger. Defaults to `None`. |

<br />

<br />

<br />

<br />

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

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `input` | Retrieves the input tensor(s) of a symbolic operation. <br /> Only returns the tensor(s) corresponding to the *first time* the operation was called. |
| `output` | Retrieves the output tensor(s) of a layer. <br /> Only returns the tensor(s) corresponding to the *first time* the operation was called. |

<br />

## Methods

### `from_config`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/operation.py#L322-L362)

    @classmethod
    from_config(
        config
    )

Creates an operation from its config.

This method is the reverse of `get_config`, capable of instantiating the
same operation from the config dictionary.

> [!NOTE]
> **Note:** If you override this method, you might receive a serialized dtype config, which is a `dict`. You can deserialize it as follows:

    if "dtype" in config and isinstance(config["dtype"], dict):
        policy = dtype_policies.deserialize(config["dtype"])

<br />

<br />

<br />

| Args ||
|---|---|
| `config` | A Python dictionary, typically the output of `get_config`. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An operation instance. ||

<br />