TorchLean API

NN.Proofs.Autograd.FDeriv.SoftmaxAxis

Softmax at arbitrary rank #

Each output coordinate belongs to one last-axis row. Selecting that row is a linear map, so the vector softmax derivative applies after row selection at every tensor rank. The coordinate identities below use the actual max-shifted specification; no uniqueness assumption on the maximum is needed.

Coordinate functions give the finite-dimensional space on which we differentiate. Constructing the input tensor and reading the output are explicit in the derivative statement.

@[reducible, inline]

Number of entries in a last-axis row; the scalar convention has one entry.

Instances For

    The last coordinate of a tensor coordinate, with index zero for a scalar.

    Instances For

      Replace the last coordinate while keeping all leading coordinates fixed.

      Instances For
        noncomputable def Proofs.Autograd.SoftmaxAxis.rowVector {s : Spec.Shape} (x : s.Coord) (p : s.Coord) :

        Read one last-axis row from a tensor's coordinate function.

        Instances For
          noncomputable def Proofs.Autograd.SoftmaxAxis.rowCLM {s : Spec.Shape} (p : s.Coord) :

          Row selection is linear and continuous on the finite coordinate space.

          Instances For
            @[simp]

            Applying the row-selection map reads exactly that row.

            The only coordinate of a one-entry softmax is one.

            A rank-one tensor's selected row is its ordinary Euclidean vectorization.

            Selecting a row after taking a leading slice selects the same coordinates.

            The stable innermost specification is the analytic vector softmax on the selected row.

            The proof reduces each leading axis structurally, then uses the proved cancellation of the max shift in the vector kernel. Empty axes require no special numerical convention: they have no output coordinate at which the equality could fail.

            noncomputable def Proofs.Autograd.SoftmaxAxis.innermostDeriv {s : Spec.Shape} (x : s.Coord) :
            (s.Coord) →L[] s.Coord

            Derivative of the innermost specification, assembled from its row derivatives.

            Instances For
              theorem Proofs.Autograd.SoftmaxAxis.softmaxJvp_one (x dx : Vec 1) (j : Fin 1) :
              (softmaxJvp x dx).ofLp j = 0

              The one-entry softmax has zero differential.