Skip to main content

log_softmax

Function log_softmax 

pub fn log_softmax<const D: usize>(
    tensor: Tensor<D>,
    dim: impl AsIndex,
) -> Tensor<D>
Expand description

Applies the log softmax function on the input tensor along the given dimension.

log_softmax(x_i) = log(softmax(x_i)) = log(exp(x_i) / sum_j(exp(x_j)))

§Arguments

  • dim: the dimension along which Log Softmax will be computed. Negative dimensions are supported and count from the end.

§Panics

  • If dim is outside [-D, D)