mirror of
https://github.com/pytorch/pytorch.git
synced 2026-11-20 09:04:25 +08:00
19da3da3d3
The fix-cpp-build branch is a major restructuring that: - Drops Exhale (which auto-generated API docs but caused OOM in CI) in favor of hand-written RST pages using Breathe directives - Reorganizes notes into a hierarchical API reference with proper categories - Adds new content: XPU docs, stable ABI docs, DeviceGuard/Stream docs - Always runs Doxygen instead of gating on an env var Pull Request resolved: https://github.com/pytorch/pytorch/pull/174096 Approved by: https://github.com/janeyx99, https://github.com/seemethere, https://github.com/albanD
1.3 KiB
1.3 KiB
myst
| myst | ||||||
|---|---|---|---|---|---|---|
|
Embedding Layers
Embedding layers map discrete tokens (words, categories, IDs) to dense vector representations. They are the foundation of NLP models and recommendation systems.
- Embedding: Standard lookup table that maps indices to dense vectors
- EmbeddingBag: Computes sums or means of embeddings (efficient for sparse features)
Key parameters:
num_embeddings: Size of the vocabulary (number of unique tokens)embedding_dim: Dimension of each embedding vectorpadding_idx: Index that outputs zeros (useful for padding tokens)
Embedding
:members:
:undoc-members:
:members:
:undoc-members:
Example:
auto embedding = torch::nn::Embedding(
torch::nn::EmbeddingOptions(10000, 256) // num_embeddings, embedding_dim
.padding_idx(0));
auto indices = torch::tensor({1, 2, 3, 4});
auto embedded = embedding->forward(indices); // [4, 256]
EmbeddingBag
:members:
:undoc-members:
:members:
:undoc-members: