Contents

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

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

See Also

Activation Functions