Learn Before
Concept
Embedding Layer Mapping Token Indices to Vectors
An embedding layer operates by mapping a token's integer index directly to the row of its learnable weight matrix. The shape of this weight matrix is defined by the dictionary size as the number of rows and the vector dimension as the number of columns. When an embedding layer processes a minibatch of token indices, it retrieves the corresponding vector for each index, effectively appending the vector dimension to the input's shape. For instance, an input of shape mapped to a vector dimension of will result in an output tensor of shape .
0
1
Updated 2026-05-25
Tags
D2L
Dive into Deep Learning @ D2L