log_softmax(input: Tensor, dim: _int = ..., dtype: DTypeLike | None = ...)Implementing kernel
C++ engine symbols that back this Python API.Numerically stable log-softmax along a dimension.
Parameters
inputTensorInput logits of any shape.
dimint or NoneDimension along which the log-softmax is computed.
_stacklevelintInternal stack level for the implicit-dimension warning.
dtypeDTypeLike or NoneTarget floating-point dtype to cast
input to before log-softmax.Returns
TensorLog-probabilities of the same shape as input.
Notes
Pairing log_softmax with nll_loss is numerically equivalent
to — and more stable than — softmax followed by cross_entropy.
Examples
>>> import lucid
>>> from lucid.nn.functional import log_softmax
>>> logits = lucid.tensor([[1.0, 2.0, 3.0]])
>>> log_softmax(logits, dim=1)
tensor([[-2.408, -1.408, -0.4076]])