Exemplo n.º 1
0
        public void Backward()
        {
            if (ParentFunc != null)
            {
                for (int i = 0; i < Grad.Length; i++)
                {
                    Grad[i] = 1;
                }

                NdArray.Backward(this);
            }
        }
Exemplo n.º 2
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]);
                    }
                }
            }
        }