softmax
An activation function that returns the softmax function of its input.
Declaration
static var softmax: BNNSActivationFunction { get }Discussion
This constant defines an activation function that returns values using the following formula:
[Image]
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 |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Changing the fourth element from 6.0 to 10.0 increases its probability to almost 1.0:
Inputs | Outputs |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|