Python wrappers
Public Python APIs implemented by this engine symbols.Autograd node for the numerically stable log-softmax along a single axis .
Computing directly (rather than of ) is the standard numerical-stability win when the downstream loss is NLL / cross-entropy: it avoids the catastrophic cancellation that arises when underflows to zero before the log step. Forward saves the log-softmax output on the node, which the backward reuses to recover the probabilities as .
Math
\qquad \frac{\partial L}{\partial x_i} = \frac{\partial L}{\partial y_i} - e^{y_i}\,\sum_j \frac{\partial L}{\partial y_j}$$ Here $e^{y_i} = p_i$ is the underlying softmax probability. **Shape** Input and output share the same shape; normalisation contracts along `axis_` only.Attributes
schema_v1OpSchema"log_softmax", AmpPolicy::ForceFP32.axis_intforward.saved_output_StorageRaises
IndexError[0, ndim).Notes
LogSoftmax is preferred over log(softmax(x)) because it remains
finite when probabilities underflow: the subtraction is performed in
the log domain via logsumexp rather than producing zero and then
taking the log.
Static methods
1Validate the axis, dispatch the forward log-softmax, save its output, and wire autograd back to a.
Parameters
aTensorImplPtraxisintReturns
TensorImplPtrLog-softmax output with the same shape and dtype as a.