<!--
{
  "availability" : [
    "*: -",
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNS/ActivationFunction/softmax",
  "metadataVersion" : "0.1.0",
  "role" : "Case",
  "symbol" : {
    "kind" : "Case",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4BNNSO18ActivationFunctionO7softmaxyA2EmF"
  },
  "title" : "BNNS.ActivationFunction.softmax"
}
-->

# BNNS.ActivationFunction.softmax

An activation function that returns the softmax function of its input.

```
case softmax
```

## Discussion

This constant defines an activation function that returns values using the following formula:

![General formula that describes mathematically the softmax activation function. s open bracket x sub i close bracket equals  the exponential of x sub i over summation from j equals one to n times the exponential of x sub j.](images/com.apple.accelerate/media-3654663@2x.png)

The softmax function transforms a vector of real numbers into a vector of probabilities. Each probability in the result is in the range 0…1, and the sum of the probabilities is 1.

For example, given and array that contains the values `[3.0, 5.0, 1.0, 6.0, 2.0, 1.0, 4.0]`, the softmax function calculates the following values:

|Inputs|Outputs      |
|------|-------------|
|`3.0` |`0.031415492`|
|`5.0` |`0.23213086` |
|`1.0` |`0.004251625`|
|`6.0` |`0.63099706` |
|`2.0` |`0.011557114`|
|`1.0` |`0.004251625`|
|`4.0` |`0.08539616` |

Changing the fourth element from `6.0` to `10.0` increases its probability to almost 1.0:

|Inputs|Outputs        |
|------|---------------|
|`3.0` |`0.00090221845`|
|`5.0` |`0.0066665425` |
|`1.0` |`0.00012210199`|
|`10.0`|`0.98940265`   |
|`2.0` |`0.00033190762`|
|`1.0` |`0.00012210199`|
|`4.0` |`0.002452484`  |

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)