TorchLean API

NN.Proofs.Autograd.FDeriv.SoftmaxSpec

Softmax and log-softmax: spec definitions versus analytic presentation #

NN.Proofs.Autograd.FDeriv.Softmax and NN.Proofs.Autograd.FDeriv.LogSoftmax prove Fréchet-derivative facts about softmaxVec and logSoftmaxVec, which are stated directly on Euclidean vectors. The specification layer instead defines Activation.softmaxVecSpec and Activation.logSoftmaxVecSpec on tensors, using the numerically stable max-shifted form.

This file closes that gap over :

Softmax #

The spec softmax kernel is the analytic softmaxVec after vectorization.

softmaxVecSpec on a vector built from Euclidean coordinates.

The vectorized forward map of Spec.softmaxOp 0 on vectors is softmaxVec.

Axis-0 spec softmax on vectors is Fréchet-differentiable with derivative softmaxDerivCLM.

The spec softmax VJP is the analytic softmaxJvp (the softmax Jacobian is symmetric).

Spec.softmaxOp 0 on vectors with its analytic JVP and the VJP/JVP adjointness law.

Instances For

    Spec.softmaxOp 0 on vectors is analytically correct: its JVP is the Fréchet derivative.

    Instances For

      The spec softmax backward is the vector-Jacobian product of the spec softmax forward.

      Log-softmax #

      The spec log-softmax kernel is the analytic logSoftmaxVec after vectorization.

      The vectorized forward map of Spec.logSoftmaxOp 0 on vectors is logSoftmaxVec.

      Axis-0 spec log-softmax on vectors is Fréchet-differentiable with derivative logSoftmaxDerivCLM.

      Exponentiating the spec log-softmax output recovers the analytic softmax coordinates.

      The spec log-softmax VJP, evaluated on the recomputed forward output, is the analytic logSoftmaxVjp.

      Spec.logSoftmaxOp 0 on vectors with its analytic JVP and the VJP/JVP adjointness law.

      Instances For

        Spec.logSoftmaxOp 0 on vectors is analytically correct: its JVP is the Fréchet derivative.

        Instances For

          The spec log-softmax backward is the vector-Jacobian product of the spec log-softmax forward.