Backends/SiaNet.Backend.MxNet/NDArrayOps.cs
/// <summary>
/// Make your own loss function in network construction.This operator accepts a customized loss function symbol as a terminal loss andthe symbol should be an operator with no backward dependency.The output of this function is the gradient of loss with respect to the input data.For example, if you are a making a cross entropy loss function. Assume ``out`` is thepredicted output and ``label`` is the true label, then the cross entropy can be defined as::  cross_entropy = label * log(out) + (1 - label) * log(1 - out)  loss = MakeLoss(cross_entropy)We will need to use ``MakeLoss`` when we are creating our own loss function or we want tocombine multiple loss functions. Also we may want to stop some variables' gradientsfrom backpropagation. See more detail in ``BlockGrad`` or ``stop_gradient``.In addition, we can give a scale to the loss by setting ``grad_scale``,so that the gradient of the loss will be rescaled in the backpropagation... note:: This operator should be used as a Symbol instead of NDArray.Defined in G:\deeplearn\mxnet\src\operator\make_loss.cc:L70
/// </summary>
/// <param name="data">Input array.</param>
/// <param name="grad_scale">Gradient scale as a supplement to unary and binary operators</param>
/// <param name="valid_thresh">clip each element in the array to 0 when it is less than ``valid_thresh``. This is used when ``normalization`` is set to ``'valid'``.</param>
/// <param name="normalization">If this is set to null, the output gradient will not be normalized. If this is set to batch, the output gradient will be divided by the batch size. If this is set to valid, the output gradient will be divided by the number of valid input elements.</param>
/// <returns>returns new symbol</returns>
Make your own loss function in network construction.This operator accepts a customized loss function symbol as a terminal loss andthe symbol should be an operator with no backward dependency.The output of this function is the gradient of loss with respect to the input data.For example, if you are a making a cross entropy loss function.
Make your own loss function in network construction . This operator accepts a customized loss function symbol as a terminal loss andthe symbol should be an operator with no backward dependency . The output of this function is the gradient of loss with respect to the input data . For example if you are a making a cross entropy loss function .
public static NDArray MakeLoss(NDArray data,
        float grad_scale = 1f,
        float valid_thresh = 0f,
        MakelossNormalization normalization = MakelossNormalization.Null)
        {
            return new Operator("MakeLoss")
            .SetParam("grad_scale", grad_scale)
            .SetParam("valid_thresh", valid_thresh)
            .SetParam("normalization", NDUtil.EnumToString<MakelossNormalization>(normalization, MakelossNormalizationConvert))
            .SetInput("data", data)
            .Invoke();
        }
public static NDArray MakeLoss ( NDArray data , float grad_scale = 1f , float valid_thresh = 0f , MakelossNormalization normalization = MakelossNormalization . Null ) { return new Operator ( " " ) . SetParam ( " " , grad_scale ) . SetParam ( " " , valid_thresh ) . SetParam ( " " , NDUtil . EnumToString < MakelossNormalization > ( normalization , MakelossNormalizationConvert ) ) . SetInput ( " " , data ) . Invoke ( ) ; }
Make your own loss function in network construction.This operator accepts a customized loss function symbol as a terminal loss andthe symbol should be an operator with no backward dependency.The output of this function is the gradient of loss with respect to the input data.For example, if you are a making a cross entropy loss function.
Make your own loss function in network construction . This operator accepts a customized loss function symbol as a terminal loss andthe symbol should be an operator with no backward dependency . The output of this function is the gradient of loss with respect to the input data . For example if you are a making a cross entropy loss function .
returns new symbol
returns new symbol
data
NDArray
None
grad_scale
float
Gradient scale as a supplement to unary and binary operators
Gradient scale as a supplement to unary and binary operators
valid_thresh
float
clip each element in the array to 0 when it is less than ``valid_thresh``. This is used when ``normalization`` is set to ``'valid'``.
clip each element in the array to 0 when it is less than ` ` valid_thresh ` ` . This is used when ` ` normalization ` ` is set to ` ` ' valid ' ` ` .
normalization
MakelossNormalization
If this is set to null, the output gradient will not be normalized. If this is set to batch, the output gradient will be divided by the batch size. If this is set to valid, the output gradient will be divided by the number of valid input elements.
If this is set to null the output gradient will not be normalized . If this is set to batch the output gradient will be divided by the batch size . If this is set to valid the output gradient will be divided by the number of valid input elements .