Rate this Page

Class EmbeddingImpl#

Inheritance Relationships#

Base Type#

Class Documentation#

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

Performs a lookup in a fixed size embedding table.

See https://pytorch.org/docs/main/nn.html#torch.nn.Embedding 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.

Example:

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

Public Functions

inline EmbeddingImpl(int64_t num_embeddings, int64_t embedding_dim)#
explicit EmbeddingImpl(EmbeddingOptions options_)#
virtual void reset() override#

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

void reset_parameters()#
virtual 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.