Class EmbeddingImpl

Inheritance Relationships

Base Type

Class Documentation

class torch::nn::EmbeddingImpl : public torch::nn::Cloneable<EmbeddingImpl>

Performs a lookup in a fixed size embedding table.

See to learn about the exact behavior of this module.

See the documentation for torch::nn::EmbeddingOptions class to learn what constructor arguments are supported for this module.


Embedding model(EmbeddingOptions(10, 2).padding_idx(3).max_norm(2).norm_type(2.5).scale_grad_by_freq(true).sparse(true));

Public Functions

EmbeddingImpl(int64_t num_embeddings, int64_t embedding_dim)
EmbeddingImpl(const EmbeddingOptions &options_)
void reset() override

reset() must perform initialization of all members with reference semantics, most importantly parameters, buffers and submodules.

void reset_parameters()
void pretty_print(std::ostream &stream) const override

Pretty prints the Embedding module into the given stream.

Tensor forward(const Tensor &indices)

Performs a lookup on the embedding table stored in weight using the indices supplied and returns the result.

Public Members

EmbeddingOptions options

The Options used to configure this Embedding module.

Changes to EmbeddingOptions after construction have no effect.

Tensor weight

The embedding table.


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources