softmax | R Documentation |
This function computes the softmax of a vector x
, with special handling for infinite values.
The softmax function transforms input values into a probability distribution by exponentiating
each value, then normalizing by the sum of all exponentiated values.
The function ensures numerical stability, particularly when dealing with very large or very small values,
and handles cases where the values are infinite (Inf
).
softmax(x)
x |
A numeric vector for which the softmax function will be calculated. |
A numeric vector of the same length as x
, where the values represent probabilities summing to 1.
softmax(c(10, 5, 2))
softmax(c(Inf, -Inf, 0))
softmax(c(-Inf, -Inf, -Inf))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.