Embedding
Function
Map discrete indexes to continuous vectors (for table lookup).
Prototype
torch.nn.Embedding(
num_embeddings: int,
embedding_dim: int,
padding_idx: Optional[int] = None,
max_norm: Optional[float] = None,
norm_type: float = 2.0,
scale_grad_by_freq: bool = False,
sparse: bool = False,
_weight: Optional[Tensor] = None,
device=None,
dtype=None
)
Parameters
Parameter |
Type |
Mandatory (Yes/No) |
Description |
|---|---|---|---|
num_embeddings |
int |
Yes |
Size of the embedding dictionary (index range: [0, num_embeddings-1]) |
embedding_dim |
int |
Yes |
Embedding vector dimension |
padding_idx |
int |
No |
Padding index (the vector gradient corresponding to this index is fixed at 0) |
max_norm |
float |
No |
Maximum norm constraint (scaling is performed when the constraint is exceeded) |
norm_type |
float |
No |
Norm calculation type (2.0 by default, indicating the L2 norm) |
scale_grad_by_freq |
bool |
No |
Whether to scale gradients by frequency (default value: False) |
sparse |
bool |
No |
Whether to use sparse gradients (default value: False) |
Parent topic: Operator Interfaces