Formula

Batched Softmax Function

The batched softmax function applies the softmax operation row-wise to map a matrix of raw scalar outputs, denoted as X\mathbf{X}, into a matrix where each row represents a valid probability distribution. It transforms each element into a non-negative number and ensures that each row sums to 1. Computing this row-wise softmax involves three steps: first, exponentiating each element of the matrix; second, computing a normalization constant for each row by summing its exponentiated elements; and third, dividing each element by its corresponding row's normalization constant. The mathematical formula is expressed as: softmax(X)ij=exp(Xij)kexp(Xik)\mathrm{softmax}(\mathbf{X})_{ij} = \frac{\exp(\mathbf{X}_{ij})}{\sum_k \exp(\mathbf{X}_{ik})}

0

1

Updated 2026-06-27

Tags

D2L

Dive into Deep Learning @ D2L

Related