Example #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);
            }
        }
Example #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);
            }
        }
Example #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]);
                    }
                }
            }
        }
Example #4
0
 //Backward
 public override void Backward(params NdArray[] ys)
 {
     NdArray.Backward(ys[0]);
 }
Example #5
0
 //Backward
 public void BackwardFD(params NdArray <T>[] ys)
 {
     NdArray.Backward(ys[0]);
 }