Class EmbeddingBagImpl¶
Defined in File embedding.h
Page Contents
Inheritance Relationships¶
Base Type¶
public torch::nn::Cloneable< EmbeddingBagImpl >
(Template Class Cloneable)
Class Documentation¶
-
class EmbeddingBagImpl : public torch::nn::Cloneable<EmbeddingBagImpl>¶
Computes sums or means of ‘bags’ of embeddings, without instantiating the intermediate embeddings.
See https://pytorch.org/docs/main/nn.html#torch.nn.EmbeddingBag to learn about the exact behavior of this module.
See the documentation for
torch::nn::EmbeddingBagOptions
class to learn what constructor arguments are supported for this module.Example:
EmbeddingBag model(EmbeddingBagOptions(10, 2).max_norm(2).norm_type(2.5).scale_grad_by_freq(true).sparse(true).mode(torch::kSum).padding_idx(1));
Public Functions
-
inline EmbeddingBagImpl(int64_t num_embeddings, int64_t embedding_dim)¶
-
explicit EmbeddingBagImpl(EmbeddingBagOptions 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
EmbeddingBag
module into the givenstream
.
-
Tensor forward(const Tensor &input, const Tensor &offsets = {}, const Tensor &per_sample_weights = {})¶
Public Members
-
EmbeddingBagOptions options¶
The
Options
used to configure thisEmbeddingBag
module.
-
Tensor weight¶
The embedding table.
Protected Functions
-
inline virtual bool _forward_has_default_args() override¶
The following three functions allow a module with default arguments in its forward method to be used in a Sequential module.
You should NEVER override these functions manually. Instead, you should use the
FORWARD_HAS_DEFAULT_ARGS
macro.
-
inline virtual unsigned int _forward_num_required_args() override¶
Friends
- friend struct torch::nn::AnyModuleHolder
-
inline EmbeddingBagImpl(int64_t num_embeddings, int64_t embedding_dim)¶