Esempio n. 1
0
 public override void Backward(NDarray <double> dY)
 {
     left.Grad  = ND.AddBCleft(left.Grad, ND.Dot(dY, Yr.T));
     right.Grad = ND.AddBCleft(right.Grad, ND.Dot(Yl.T, dY));
     left.Backward(left.Grad);
     right.Backward(right.Grad);
 }
Esempio n. 2
0
        public override void Forward()
        {
            left.Forward();
            right.Forward();
            Yl = left.Y;
            Yr = right.Y;
            Y  = ND.Dot(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);
            }
        }