Backends/SiaNet.Backend.MxNet/NDArrayOps.cs
/// <summary>
/// Sets all elements outside the sequence to a constant value.This function takes an n-dimensional input array of the form[max_sequence_length, batch_size, other_feature_dims] and returns an array of the same shape.Parameter `sequence_length` is used to handle variable-length sequences. `sequence_length`should be an input array of positive ints of dimension [batch_size].To use this parameter, set `use_sequence_length` to `True`,otherwise each example in the batch is assumed to have the max sequence length andthis operator works as the `identity` operator.Example::   x = [[[  1.,   2.,   3.],         [  4.,   5.,   6.]],        [[  7.,   8.,   9.],         [ 10.,  11.,  12.]],        [[ 13.,  14.,   15.],         [ 16.,  17.,   18.]]]   // Batch 1   B1 = [[  1.,   2.,   3.],         [  7.,   8.,   9.],         [ 13.,  14.,  15.]]   // Batch 2   B2 = [[  4.,   5.,   6.],         [ 10.,  11.,  12.],         [ 16.,  17.,  18.]]   // works as identity operator when sequence_length parameter is not used   SequenceMask(x) = [[[  1.,   2.,   3.],                       [  4.,   5.,   6.]],                      [[  7.,   8.,   9.],                       [ 10.,  11.,  12.]],                      [[ 13.,  14.,   15.],                       [ 16.,  17.,   18.]]]   // sequence_length [1,1] means 1 of each batch will be kept   // and other rows are masked with default mask value = 0   SequenceMask(x, y=[1,1], use_sequence_length=True) =                [[[  1.,   2.,   3.],                  [  4.,   5.,   6.]],                 [[  0.,   0.,   0.],                  [  0.,   0.,   0.]],                 [[  0.,   0.,   0.],                  [  0.,   0.,   0.]]]   // sequence_length [2,3] means 2 of batch B1 and 3 of batch B2 will be kept   // and other rows are masked with value = 1   SequenceMask(x, y=[2,3], use_sequence_length=True, value=1) =                [[[  1.,   2.,   3.],                  [  4.,   5.,   6.]],                 [[  7.,   8.,   9.],                  [  10.,  11.,  12.]],                 [[   1.,   1.,   1.],                  [  16.,  17.,  18.]]]Defined in G:\deeplearn\mxnet\src\operator\sequence_mask.cc:L113
/// </summary>
/// <param name="data">n-dimensional input array of the form [max_sequence_length, batch_size, other_feature_dims] where n>2</param>
/// <param name="sequence_length">vector of sequence lengths of the form [batch_size]</param>
/// <param name="use_sequence_length">If set to true, this layer takes in an extra input parameter `sequence_length` to specify variable length sequence</param>
/// <param name="value">The value to be used as a mask.</param>
/// <returns>returns new symbol</returns>
Sets all elements outside the sequence to a constant value.This function takes an n-dimensional input array of the form[max_sequence_length, batch_size, other_feature_dims] and returns an array of the same shape.Parameter `sequence_length` is used to handle variable-length sequences.
Sets all elements outside the sequence to a constant value . This function takes an n - dimensional input array of the form [ max_sequence_length batch_size other_feature_dims ] and returns an array of the same shape . Parameter ` sequence_length ` is used to handle variable - length sequences .
public static NDArray SequenceMask(NDArray data,
        NDArray sequence_length,
        bool use_sequence_length = false,
        float value = 0f)
        {
            return new Operator("SequenceMask")
            .SetParam("use_sequence_length", use_sequence_length)
            .SetParam("value", value)
            .SetInput("data", data)
            .SetInput("sequence_length", sequence_length)
            .Invoke();
        }
public static NDArray SequenceMask ( NDArray data , NDArray sequence_length , bool use_sequence_length = false , float value = 0f ) { return new Operator ( " " ) . SetParam ( " " , use_sequence_length ) . SetParam ( " " , value ) . SetInput ( " " , data ) . SetInput ( " " , sequence_length ) . Invoke ( ) ; }
Sets all elements outside the sequence to a constant value.This function takes an n-dimensional input array of the form[max_sequence_length, batch_size, other_feature_dims] and returns an array of the same shape.Parameter `sequence_length` is used to handle variable-length sequences.
Sets all elements outside the sequence to a constant value . This function takes an n - dimensional input array of the form [ max_sequence_length batch_size other_feature_dims ] and returns an array of the same shape . Parameter ` sequence_length ` is used to handle variable - length sequences .
returns new symbol
returns new symbol
data
NDArray
n-dimensional input array of the form [max_sequence_length, batch_size, other_feature_dims] where n>2
n - dimensional input array of the form [ max_sequence_length batch_size other_feature_dims ] where n > 2
sequence_length
NDArray
vector of sequence lengths of the form [batch_size]
vector of sequence lengths of the form [ batch_size ]
use_sequence_length
bool
If set to true, this layer takes in an extra input parameter `sequence_length` to specify variable length sequence
If set to true this layer takes in an extra input parameter ` sequence_length ` to specify variable length sequence
value
float
The value to be used as a mask.
The value to be used as a mask .