Esempio n. 1
0
        public static void Backward(this NdArray <Real> ndArray)
        {
            if (ndArray.ParentFunc != null)
            {
                if (ndArray.Grad == null)
                {
                    ndArray.Grad = new Real[ndArray.Length * ndArray.BatchCount];

                    for (int i = 0; i < ndArray.Grad.Length; i++)
                    {
                        ndArray.Grad[i] = 1;
                    }
                }

                NdArray.Backward(ndArray);
            }
        }
Esempio n. 2
0
        public void Backward()
        {
            if (this.ParentFunc != null)
            {
                if (this.Grad == null)
                {
                    this.Grad = new Real[this.Length * this.BatchCount];

                    for (int i = 0; i < this.Grad.Length; i++)
                    {
                        Grad[i] = 1;
                    }
                }

                NdArray.Backward(this);
            }
        }
Esempio n. 3
0
        public static void Backward(NdArray y)
        {
            if (y.ParentFunc != null)
            {
                List <NdArray[]> prevInputs = y.ParentFunc.PrevInputs;
                NdArray[]        xs         = prevInputs[prevInputs.Count - 1];

                y.ParentFunc.Backward(y);

                for (int i = 0; i < xs.Length; i++)
                {
                    if (xs[i].UseCount == 0)
                    {
                        NdArray.Backward(xs[i]);
                    }
                }
            }
        }
Esempio n. 4
0
 //Backward
 public override void Backward(params NdArray[] ys)
 {
     NdArray.Backward(ys[0]);
 }
Esempio n. 5
0
 //Backward
 public void BackwardFD(params NdArray <T>[] ys)
 {
     NdArray.Backward(ys[0]);
 }