Soft-Max function
Softmax for a vector x is defined as
softmax(x) dsoftmax(x)
x
: A numeric vector or matrixsoftmax
returns the softmax of x
; rowwise if x
is a matrix.
dsoftmax
returns the Jacobi-matrix of softmax(x)
at x
. x
must be a vector.
It satisfies sum(s) == 1.0
and can be used to smoothly enforce a sum constraint.
softmax(c(5, 5)) softmax(diag(nrow = 5, ncol = 6))
Useful links