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 ℝ:
getScalarE_softmaxVecSpecandgetScalarE_logSoftmaxVecSpecidentify the spec kernels with the analytic definitions after vectorization;hasFDerivAt_softmaxSpec_vecandhasFDerivAt_logSoftmaxSpec_vectransfer differentiability toActivation.softmaxSpec 0andActivation.logSoftmaxSpec 0;softmaxFDerivCorrectandlogSoftmaxFDerivCorrectpackageSpec.softmaxOp 0andSpec.logSoftmaxOp 0asOpSpecFDerivCorrect, so their backward rules are proved to be the adjoint of the true derivative (softmaxBackwardSpec_eq_vjp,logSoftmaxBackwardSpec_eq_vjp).
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.