Class EmbeddingLookup
- Namespace
- NeuralNetworks.Operations.Parameterized
- Assembly
- NeuralNetworks.dll
Embedding lookup operation that maps integer indices to embedding vectors.
public class EmbeddingLookup : ParamOperation<int[,], float[,], float[,]>, IParamOperation
- Inheritance
-
EmbeddingLookup
- Implements
- Inherited Members
Remarks
Initializes a new instance of the EmbeddingLookup class.
Constructors
EmbeddingLookup(float[,])
Embedding lookup operation that maps integer indices to embedding vectors.
public EmbeddingLookup(float[,] embeddings)
Parameters
embeddingsfloat[,]Embedding matrix [vocabSize, embeddingDim].
Remarks
Initializes a new instance of the EmbeddingLookup class.
Methods
CalcInputGradient(float[,])
Calculates the gradient of the input indices based on the output gradient.
protected override int[,] CalcInputGradient(float[,] outputGradient)
Parameters
outputGradientfloat[,]
Returns
- int[,]
Input gradient (not used for integer indices, returns zero array).
CalcOutput(bool)
protected override float[,] CalcOutput(bool inference)
Parameters
inferencebool
Returns
- float[,]
Embeddings [batchSize, sequenceLength, embeddingDim] flattened to [batchSize, sequenceLength * embeddingDim].
CalcParamGradient(float[,])
Calculates the gradient of the embedding parameters based on the output gradient.
protected override float[,] CalcParamGradient(float[,] outputGradient)
Parameters
outputGradientfloat[,]Gradient from upstream [batchSize, sequenceLength * embeddingDim].
Returns
- float[,]
ToString()
Returns a string that represents the current operation.
public override string ToString()
Returns
- string
A string that represents the current operation.
Remarks
It is used in a layer/model description.