public void Backward() { if (ParentFunc != null) { for (int i = 0; i < Grad.Length; i++) { Grad[i] = 1; } NdArray.Backward(this); } }
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]); } } } }