Embedding

torch.nn.modules.sparse.Embedding

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
Graph
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

Members list

Value members

Concrete methods

def apply(t: Tensor[Int64]): Tensor[ParamType]

Attributes

Source
Embedding.scala
override def hasBias(): Boolean

Attributes

Definition Classes
Source
Embedding.scala
override def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Source
Embedding.scala
def weight: Tensor[ParamType]

Attributes

Source
Embedding.scala
def weight_=(w: Tensor[ParamType]): Tensor[ParamType]

Attributes

Source
Embedding.scala

Inherited methods

def andThen[A](g: Tensor[ParamType] => A): T1 => A

Attributes

Inherited from:
Function1
def apply(fn: Module => Unit): Module.this.type

Attributes

Inherited from:
Module
Source
Module.scala
def compose[A](g: A => Tensor[Int64]): A => R

Attributes

Inherited from:
Function1
def eval(): Unit

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala
def load(inputArchive: InputArchive): Unit

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala
transparent inline def paramType: DType

Attributes

Inherited from:
HasParams
Source
Module.scala
override def parameters(recurse: Boolean): Seq[Tensor[ParamType]]

Attributes

Definition Classes
Inherited from:
HasParams
Source
Module.scala
override def parameters: Seq[Tensor[ParamType]]

Attributes

Definition Classes
Inherited from:
HasParams
Source
Module.scala
def register[M <: Module](child: M, n: String)(using name: Name): M

Attributes

Inherited from:
Module
Source
Module.scala

Adds a buffer to the module.

Adds a buffer to the module.

Attributes

Inherited from:
Module
Source
Module.scala
def registerBuffer[D <: DType](t: Tensor[D], n: String)(using name: Name): Tensor[D]

Attributes

Inherited from:
Module
Source
Module.scala
def registerModule[M <: Module](child: M, n: String)(using name: Name): M

Attributes

Inherited from:
Module
Source
Module.scala
def registerParameter[D <: DType](t: Tensor[D], requiresGrad: Boolean, n: String)(using name: Name): Tensor[D]

Attributes

Inherited from:
Module
Source
Module.scala
def save(outputArchive: OutputArchive): Unit

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala
def to(device: Device): Module.this.type

Attributes

Inherited from:
Module
Source
Module.scala
def train(on: Boolean): Unit

Attributes

Inherited from:
Module
Source
Module.scala

Concrete fields

override val nativeModule: EmbeddingImpl

Attributes

Source
Embedding.scala