SiaNet/Layers/Core/Dense.cs
/// <summary>
/// Calculate the gradient of this layer function
/// </summary>
/// <param name="outputgrad">The calculated output grad from previous layer.</param>
Calculate the gradient of this layer function
Calculate the gradient of this layer function
public override void Backward(Tensor outputgrad)
        {
            if (Act != null)
            {
                Act.Backward(outputgrad);
                outputgrad = Act.Input.Grad;
            }
            Input.Grad = K.Dot(outputgrad, base["w"].Data.Transpose());
            this["w"].Grad = K.Dot(Input.Data.Transpose(), outputgrad);
            if (UseBias)
                this["b"].Grad = K.Sum(outputgrad, 0);
        }
public override void Backward ( Tensor outputgrad ) { if ( Act != null ) { Act . Backward ( outputgrad ) ; outputgrad = Act . Input . Grad ; } Input . Grad = K . Dot ( outputgrad , base [ " " ] . Data . Transpose ( ) ) ; this [ " " ] . Grad = K . Dot ( Input . Data . Transpose ( ) , outputgrad ) ; if ( UseBias ) this [ " " ] . Grad = K . Sum ( outputgrad , 0 ) ; }
Calculate the gradient of this layer function
Calculate the gradient of this layer function
outputgrad
Tensor
The calculated output grad from previous layer.
The calculated output grad from previous layer .