Learn Before
Concept

Embedding Layer Mapping Token Indices to Vectors

An embedding layer operates by mapping a token's integer index ii directly to the ithi^\textrm{th} 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 (2,3)(2, 3) mapped to a vector dimension of 44 will result in an output tensor of shape (2,3,4)(2, 3, 4).

0

1

Updated 2026-05-25

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L