protected override NdArray[] SingleInputForward(NdArray x) { NdArray[] resultArrays = NdArray.Split(x, Indices, Axis); for (int i = 0; i < resultArrays.Length; i++) { resultArrays[i].ParentFunc = this; } return(resultArrays); }
protected NdArray <T>[] SplitAxisForward(NdArray <T> x) { NdArray <T>[] resultArrays = NdArray.Split(x, Indices, Axis); for (int i = 0; i < resultArrays.Length; i++) { resultArrays[i].ParentFunc = this; } return(resultArrays); }
private NdArray[] ForwardCpu(NdArray x) { NdArray[] resultArrays = NdArray.Split(x, Indices, Axis); for (int i = 0; i < resultArrays.Length; i++) { resultArrays[i].ParentFunc = this; } return(resultArrays); }
private void BackwardCpu(NdArray y, NdArray[] xs) { int[] prevInputShapes = this._prevInputSections[this._prevInputSections.Count - 1]; this._prevInputSections.RemoveAt(this._prevInputSections.Count - 1); NdArray[] result = NdArray.Split(y, prevInputShapes, this.Axis); for (int i = 0; i < xs.Length; i++) { for (int j = 0; j < xs[i].Grad.Length; j++) { xs[i].Grad[j] += result[i].Grad[j]; } } }
public static void MultiOutputBackward(NdArray <Real> y, NdArray <Real>[] xs, int axis, List <int[]> prevInputSections) { int[] prevInputShapes = prevInputSections[prevInputSections.Count - 1]; prevInputSections.RemoveAt(prevInputSections.Count - 1); NdArray <Real>[] result = NdArray.Split(y, prevInputShapes, axis); for (int i = 0; i < xs.Length; i++) { for (int j = 0; j < xs[i].Grad.Length; j++) { xs[i].Grad[j] += result[i].Grad[j]; } } }