Beispiel #1
0
 public override LMatrix backward(LMatrix dout)
 {
     dB = dout.Sum(0);
     dW = X.T * dout;
     return(dout * W.T);
     //LMatrix dx = dout * W.T;
     //dW = X.T * dout;
     //dB = dout.Sum(0);
     //return dx.ReShape(X.Row, X.Column);
 }
Beispiel #2
0
        private LMatrix _backward(LMatrix dout)
        {
            dbeta  = dout.Sum(0);
            dgamma = (xn & dout).Sum(0);
            LMatrix dxn  = dout & gamma;
            LMatrix dxc  = dxn / this.std;
            LMatrix dstd = ((dxn & xc) / (std & std)).Sum(0) * -1;
            LMatrix dvar = (dstd & 0.5) / this.std;

            dxc = dxc + (this.xc & dvar & (2.0 / this.batch_size));
            LMatrix dmu = dxc.Sum(0);
            LMatrix dx  = dxc - dmu / this.batch_size;

            this.dgamma = dgamma;
            this.dbeta  = dbeta;
            return(dx);
        }