Class EmbeddingImpl¶
Defined in File embedding.h
Page Contents
Inheritance Relationships¶
Base Type¶
public torch::nn::Cloneable< EmbeddingImpl >
(Template Class Cloneable)
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 givenstream
.
-
Tensor forward(const Tensor &indices)¶
Performs a lookup on the embedding table stored in
weight
using theindices
supplied and returns the result.
Public Members
-
EmbeddingOptions options¶
The
Options
used to configure thisEmbedding
module.Changes to
EmbeddingOptions
after construction have no effect.
-
Tensor weight¶
The embedding table.
-
inline EmbeddingImpl(int64_t num_embeddings, int64_t embedding_dim)¶