Class Embedding
Turns positive integers (indexes) into dense vectors of fixed size. eg. [[4], [20]] -> [[0.25, 0.1], [0.6, -0.2]]
This layer can only be used as the first layer in a model.
Inherited Members
Namespace: SiaNet.Layers
Assembly: SiaNet.dll
Syntax
public class Embedding : BaseLayer
Constructors
| Improve this Doc View SourceEmbedding(Int32, Int32, BaseInitializer, BaseRegularizer, BaseConstraint)
Initializes a new instance of the Embedding class.
Declaration
public Embedding(int inputDim, int outputDim, BaseInitializer embeddingsInitializer = null, BaseRegularizer embeddingsRegularizer = null, BaseConstraint embeddingsConstraint = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | inputDim | Size of the vocabulary, i.e. maximum integer index + 1. |
System.Int32 | outputDim | int >= 0, Dimension of the dense embedding. |
BaseInitializer | embeddingsInitializer | Initializer for the embedding weight matrix. |
BaseRegularizer | embeddingsRegularizer | Regularizer function for the embedding weight matrix. |
BaseConstraint | embeddingsConstraint | Constraint function for the embedding weight matrix. |
Properties
| Improve this Doc View SourceEmbeddingsConstraint
Constraint function for the embedding weight matrix
Declaration
public BaseConstraint EmbeddingsConstraint { get; set; }
Property Value
Type | Description |
---|---|
BaseConstraint | The embeddings constraint. |
EmbeddingsInitializer
Initializer for the embedding weight matrix.
Declaration
public BaseInitializer EmbeddingsInitializer { get; set; }
Property Value
Type | Description |
---|---|
BaseInitializer | The embeddings initializer. |
EmbeddingsRegularizer
Regularizer function for the embedding weight matrix.
Declaration
public BaseRegularizer EmbeddingsRegularizer { get; set; }
Property Value
Type | Description |
---|---|
BaseRegularizer | The embeddings regularizer. |
InputDim
int > 0, Size of the vocabulary, i.e. maximum integer index + 1.
Declaration
public int InputDim { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The input dim. |
OutputDim
int >= 0, Dimension of the dense embedding.
Declaration
public int OutputDim { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The output dim. |
Methods
| Improve this Doc View SourceBackward(Tensor)
Calculate the gradient of this layer function
Declaration
public override void Backward(Tensor outputgrad)
Parameters
Type | Name | Description |
---|---|---|
Tensor | outputgrad | The calculated output grad from previous layer. |
Overrides
| Improve this Doc View SourceForward(Tensor)
Forwards the inputs and compute the output
Declaration
public override void Forward(Tensor x)
Parameters
Type | Name | Description |
---|---|---|
Tensor | x | The input tensor for this layer. |