Buyer's Guide
A Same-Shaped Softmax Output Can Normalize Across Different AI Inputs
For a handoff requiring one unit-sum class-score vector per input, the softmax denominator must sum over that input's classes. With axes explicitly declared [inputs, classes], this is dimension 1 in the historical PyTorch v2.9.0 source. Dimension 0 instead normalizes each class across the supplied input rows. Both choices preserve shape and produce bounded values. Under fixed logits, another input enters the first row's denominator only in the cross-input calculation.
01
Start with the required per-input class-score handoff
Suppose an application owner requires one class-score vector for each supplied input, with that input's scores summing to one. Declare the dense two-dimensional array's axes as [inputs, classes]: each row belongs to one input, and each column identifies the same class across inputs. These meanings are part of the handoff requirement. A square shape alone cannot supply them.
A logit here is a supplied real score before softmax normalization. The comparison uses finite, fixed logits and ordinary dense softmax, without masks, temperature changes or other score processing. Fractions below express exact real-number algebra, rather than recorded runtime outputs. Other model layers can make logits depend on batch composition; fixing the logits isolates this particular normalization operation.
The historical PyTorch v2.9.0 Softmax definition preserves input shape and associates normalization with a specified dimension. Its functional.softmax definition applies the operation along that dimension. Dimension 1 traverses classes in the declared layout; dimension 0 traverses inputs. The handoff therefore needs the axis meaning alongside the numerical dimension.
02
The denominator defines which entries compete for unit mass
Let z(i,c) denote the logit for input i and class c. Class-axis softmax gives p(i,c) = exp(z(i,c)) / sum over classes k of exp(z(i,k)). The input index i stays fixed while the denominator gathers all of that input's class terms. Every class entry in that row uses the same denominator, so the row sums to one.
Batch-axis softmax gives q(i,c) = exp(z(i,c)) / sum over inputs j of exp(z(j,c)). The class index c stays fixed while the denominator gathers that class's terms from all supplied inputs. Each column now receives one unit of mass distributed among its input rows.
Both are well-defined softmax calculations. They allocate unit mass to different populations. For the stipulated per-input handoff, the class-axis denominator expresses the required distribution. A batch-axis result would instead describe each input's share of a class column within the supplied batch.
03
AXIS22: derive the complete class-axis result
Use two fictional inputs A and B and two class positions X and Y. Keep rows in A, B order and columns in X, Y order throughout. AXIS22 supplies the logit matrix Z = [[ln(1), ln(3)], [ln(1), ln(1)]], where ln is the natural logarithm. Exponentiation gives E = [[1, 3], [1, 1]].
For class-axis normalization, A's denominator is 1 + 3 = 4. Its class-score vector is therefore [1/4, 3/4]. B's denominator is 1 + 1 = 2, giving [1/2, 1/2].
The complete class-axis result is P = [[1/4, 3/4], [1/2, 1/2]]. Each row sums to one. The columns sum to 3/4 and 5/4 respectively; the stipulated handoff imposes no unit-sum requirement on those columns.
A's denominator contains only A's two exponentiated logits. B contributes nothing to it. Consequently, changing B's supplied logits while holding A's logits and class mapping fixed leaves this class-axis result for A unchanged.
04
The same logits give a different batch-axis matrix
Return to the same E = [[1, 3], [1, 1]]. For batch-axis normalization, the X-column denominator is 1 + 1 = 2, while the Y-column denominator is 3 + 1 = 4.
A therefore receives [1/2, 3/4], and B receives [1/2, 1/4]. The complete batch-axis result is Q = [[1/2, 3/4], [1/2, 1/4]]. Each column sums to one. The row sums are 5/4 for A and 3/4 for B, so these rows do not supply the stipulated per-input distributions.
Both P and Q have shape 2 x 2, and every entry lies between zero and one. A's Y entry even equals 3/4 in both matrices: the two relevant denominators happen to equal four. That matching entry does not establish matching normalization. A's X entry changes from 1/4 to 1/2 because its denominator changes from A's class total of four to the X-column total of two.
05
Add C while keeping A's and B's logits fixed
Now append input C with logits [ln(1), ln(2)] for the same X, Y class order. Its exponentiated terms are [1, 2]. A's and B's logits remain exactly as supplied above.
With class-axis normalization, the existing row denominators remain four and two. C has its own denominator, 1 + 2 = 3. The complete extended result is P3 = [[1/4, 3/4], [1/2, 1/2], [1/3, 2/3]]. All three rows sum to one, and A and B retain their original vectors.
With batch-axis normalization, C adds a term to each existing column denominator. X now totals 1 + 1 + 1 = 3, and Y totals 3 + 1 + 2 = 6. The complete extended result is Q3 = [[1/3, 1/2], [1/3, 1/6], [1/3, 1/3]]. Its X column sums to one, and its Y column sums to 1/2 + 1/6 + 1/3 = 1.
A has changed from [1/2, 3/4] to [1/3, 1/2] in the batch-axis calculation. Its numerators are still one and three. The changed values arise entirely from larger denominators containing C's contributions. More generally, appending a finite-logit input adds a positive exponential term to each batch-axis denominator; under the fixed-logit premise, every existing entry in that column becomes smaller in exact arithmetic.
06
Interpret the handoff using its named normalization population
Consider two fictional score reports that both describe their output as a 2 x 2 array of softmax values between zero and one. One supplies P from AXIS22 and the other supplies Q. Their shape and range statements are compatible, but only P fulfills the stated requirement for a separate unit-sum class-score vector per input.
A sum observation can also be inconclusive for special inputs. If all four logits in a 2 x 2 array equal zero, either axis gives [[1/2, 1/2], [1/2, 1/2]]. Both rows and both columns sum to one. The resulting values alone cannot reveal which dimension defined the calculation.
A usable handoff identifies the input-row mapping, class-column order, normalization axis and population included in each denominator. Its explanation should connect one reported entry to that population, as AXIS22 does. When comparing reports, retain the supplied-logit basis and batch membership so that a denominator change can be distinguished from a change to the logits.
The dimension number follows the declared layout. If the axes were instead [classes, inputs], dimension 0 would traverse classes and express the per-input class normalization. The numerical dimension is therefore meaningful together with the semantic axes and the requested output. For questions about addressing and shared storage, the related tensor-view guide explains those separate tensor properties.
07
Connect a separate equipment project to physical installation
If the selected application also requires a physical equipment installation, Leviathan's rack-and-stack service covers agreed equipment mounting, IT cabling, labels and physical installation records. Use the related service and project inquiry with a nonconfidential equipment list, site and released rack/cable package to discuss that physical scope and availability. The class-score handoff remains a decision for the appointed application team.
References: [L1]
08Sources
Primary sources
- [PT1]PyTorch v2.9.0 — Softmax definitionChecked 2026-10-21. Historical Softmax formula, shape preservation and dimension-specific normalized slices. Applied here to finite dense two-dimensional logits with explicitly declared axis meanings.
- [PT2]PyTorch v2.9.0 — functional.softmax definitionChecked 2026-10-21. Historical definition and dimension-dependent calculation support the denominator comparison. AXIS22 and the zero-logit edge case are exact algebraic illustrations, with no model execution or measured result.
- [L1]Leviathan Systems — Rack & Stack / ColocationChecked 2026-10-21. Published scope for agreed equipment mounting, physical IT cabling, labels and installation records, applicable to a separately identified installation project.
Contact
Does selected equipment need physical installation?
Share a nonconfidential equipment list, site and released rack/cable package to discuss the physical installation scope and availability.