Beispiel #1
0
 public override void Backward(NDarray <double> dY)
 {
     left.Grad  = ND.AddBCleft(left.Grad, ND.Mul(dY, Yr));
     right.Grad = ND.AddBCleft(right.Grad, ND.Mul(Yl, dY));
     left.Backward(left.Grad);
     right.Backward(right.Grad);
 }
Beispiel #2
0
        public override void Forward()
        {
            left.Forward();
            right.Forward();
            Yl = left.Y;
            Yr = right.Y;
            Y  = ND.Mul(Yl, Yr);

            if (left.Grad == null)
            {
                left.Grad = new NDarray <double>(left.Y.Shape);
            }
            if (right.Grad == null)
            {
                right.Grad = new NDarray <double>(right.Y.Shape);
            }
        }
Beispiel #3
0
 public override void Backward(NDarray <double> dY)
 {
     Grad = ND.Mul(Y.ApplyFunc(grad), dY);
     function.Backward(Grad);
 }