torch.nn.modules.sparse

Members list

Grouped members

nn_sparse

A simple lookup table that stores embeddings of a fixed dictionary and size.

A simple lookup table that stores embeddings of a fixed dictionary and size.

This module is often used to store word embeddings and retrieve them using indices. The input to the module is a list of indices, and the output is the corresponding word embeddings.

Value parameters

embeddingDim

The size of each embedding vector

maxNorm

If given, each embedding vector with norm larger than maxNorm is renormalized to have norm maxNorm.

normType

The p of the p-norm to compute for the maxNorm option. Default 2.

numEmbeddings

Size of the dictionary of embeddings

paddingIdx

If specified, the entries at paddingIdx do not contribute to the gradient; therefore, the embedding vector at paddingIdx is not updated during training, i.e. it remains as a fixed "pad". For a newly constructed Embedding, the embedding vector at paddingIdx will default to all zeros, but can be updated to another value to be used as the padding vector.

scaleGradByFreq

If given, this will scale gradients by the inverse of frequency of the words in the mini-batch. Default false.

sparse

If True, gradient w.r.t. weight matrix will be a sparse tensor. See Notes for more details regarding sparse gradients.

Attributes

See also
Source
Embedding.scala
Supertypes
trait TensorModuleBase[Int64, ParamType]
trait Tensor[Int64] => Tensor[ParamType]
trait HasWeight[ParamType]
trait HasParams[ParamType]
class Module
class Object
trait Matchable
class Any
Show all