Embedding
simplegrad.nn.embedding.Embedding
Bases: Module
Lookup table that maps integer indices to dense vectors.
Weights are initialized from N(0, 1) by default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_embeddings
|
int
|
Size of the vocabulary (number of rows in the embedding table). |
required |
embedding_dim
|
int
|
Dimensionality of each embedding vector. |
required |
weight
|
Tensor | None
|
Optional pre-built embedding matrix of shape
|
None
|
dtype
|
str | None
|
Data type string. Defaults to |
None
|
Source code in simplegrad/nn/embedding.py
forward(input: Tensor) -> Tensor
Look up embeddings for the given indices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
Tensor
|
Integer tensor of indices with any shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Embedding tensor of shape |