Backends/SiaNet.Backend.MxNet/NDArrayOps.cs
/// <summary>
/// Maps integer indices to vector representations (embeddings).This operator maps words to real-valued vectors in a high-dimensional space,called word embeddings. These embeddings can capture semantic and syntactic properties of the words.For example, it has been noted that in the learned embedding spaces, similar words tendto be close to each other and dissimilar words far apart.For an input array of shape (d1, ..., dK),the shape of an output array is (d1, ..., dK, output_dim).All the input values should be integers in the range [0, input_dim).If the input_dim is ip0 and output_dim is op0, then shape of the embedding weight matrix must be(ip0, op0).By default, if any index mentioned is too large, it is replaced by the index that addressesthe last vector in an embedding matrix.Examples::  input_dim = 4  output_dim = 5  // Each row in weight matrix y represents a word. So, y = (w0,w1,w2,w3)  y = [[  0.,   1.,   2.,   3.,   4.],       [  5.,   6.,   7.,   8.,   9.],       [ 10.,  11.,  12.,  13.,  14.],       [ 15.,  16.,  17.,  18.,  19.]]  // Input array x represents n-grams(2-gram). So, x = [(w1,w3), (w0,w2)]  x = [[ 1.,  3.],       [ 0.,  2.]]  // Mapped input x to its vector representation y.  Embedding(x, y, 4, 5) = [[[  5.,   6.,   7.,   8.,   9.],                            [ 15.,  16.,  17.,  18.,  19.]],                           [[  0.,   1.,   2.,   3.,   4.],                            [ 10.,  11.,  12.,  13.,  14.]]]Defined in G:\deeplearn\mxnet\src\operator\tensor\indexing_op.cc:L74
/// </summary>
/// <param name="@out">output NDArray</param>
/// <param name="data">The input array to the embedding operator.</param>
/// <param name="input_dim">Vocabulary size of the input indices.</param>
/// <param name="output_dim">Dimension of the embedding vectors.</param>
/// <param name="weight">The embedding weight matrix.</param>
/// <param name="dtype">Data type of weight.</param>
/// <returns>returns new symbol</returns>
Maps integer indices to vector representations (embeddings).This operator maps words to real-valued vectors in a high-dimensional space,called word embeddings. These embeddings can capture semantic and syntactic properties of the words.For example, it has been noted that in the learned embedding spaces, similar words tendto be close to each other and dissimilar words far apart.For an input array of shape (d1, ..., dK),the shape of an output array is (d1, ..., dK, output_dim).All the input values should be integers in the range [0, input_dim).If the input_dim is ip0 and output_dim is op0, then shape of the embedding weight matrix must be(ip0, op0).By default, if any index mentioned is too large, it is replaced by the index that addressesthe last vector in an embedding matrix.Examples::  input_dim = 4  output_dim = 5  // Each row in weight matrix y represents a word.
Maps integer indices to vector representations ( embeddings ) . This operator maps words to real - valued vectors in a high - dimensional space called word embeddings . These embeddings can capture semantic and syntactic properties of the words . For example it has been noted that in the learned embedding spaces similar words tendto be close to each other and dissimilar words far apart . For an input array of shape ( d1 ... dK ) the shape of an output array is ( d1 ... dK output_dim ) . All the input values should be integers in the range [ 0 input_dim ) . If the input_dim is ip0 and output_dim is op0 then shape of the embedding weight matrix must be ( ip0 op0 ) . By default if any index mentioned is too large it is replaced by the index that addressesthe last vector in an embedding matrix . Examples :: input_dim = 4 output_dim = 5 // Each row in weight matrix y represents a word .
public static NDArray Embedding(NDArray @out,
        NDArray data,
        int input_dim,
        int output_dim,
        NDArray weight = null,
        DType dtype = null)
        {
            if (dtype == null) { dtype = DType.Float32; }
            return new Operator("Embedding")
            .SetParam("input_dim", input_dim)
            .SetParam("output_dim", output_dim)
            .SetParam("dtype", dtype)
            .SetInput("data", data)
            .SetInput("weight", weight)
            .Invoke(@out);
        }
public static NDArray Embedding ( NDArray @out , NDArray data , int input_dim , int output_dim , NDArray weight = null , DType dtype = null ) { if ( dtype == null ) { dtype = DType . Float32 ; } return new Operator ( " " ) . SetParam ( " " , input_dim ) . SetParam ( " " , output_dim ) . SetParam ( " " , dtype ) . SetInput ( " " , data ) . SetInput ( " " , weight ) . Invoke ( @out ) ; }
Maps integer indices to vector representations (embeddings).This operator maps words to real-valued vectors in a high-dimensional space,called word embeddings.
Maps integer indices to vector representations ( embeddings ) . This operator maps words to real - valued vectors in a high - dimensional space called word embeddings .
returns new symbol
returns new symbol
@out
NDArray
None
data
NDArray
The input array to the embedding operator.
The input array to the embedding operator .
input_dim
int
Vocabulary size of the input indices.
Vocabulary size of the input indices .
output_dim
int
Dimension of the embedding vectors.
Dimension of the embedding vectors .
weight
NDArray
The embedding weight matrix.
The embedding weight matrix .
dtype
DType
Data type of weight.
Data type of weight .