Skip to contents

Apply the softmax function to a vector of values.

Usage

softmax(x)

Arguments

x

Vector of values.

Details

Apply the softmax function to a vector of values, e.g.:

$$\text{softmax}(z_i) = \frac{e^{z_i}}{\sum_{j = 1}^K \ e^{z_j}}$$

Examples

softmax(seq(from = 0, to = 1, by = 0.25))
#> [1] 0.1140507 0.1464440 0.1880379 0.2414454 0.3100220