public void tf_sum_test() { using (var K = new TensorFlowBackend()) { var x = K.variable(array: new double[, ] { { 1, 2, 3 }, { 4, 5, 6 } }, dtype: DataType.Double); { double a = (double)K.sum(x, axis: new[] { 0, 1 }).eval(); Assert.AreEqual(21, a); double[] b = (double[])K.sum(x, axis: new[] { 0 }).eval(); Assert.AreEqual(new[] { 5.0, 7.0, 9.0 }, b); double[] c = (double[])K.sum(x, axis: new[] { 1 }).eval(); Assert.AreEqual(new[] { 6.0, 15.0 }, c); double[,] d = (double[, ])K.sum(x, axis: new int[] { }).eval(); Assert.AreEqual(new double[, ] { { 1, 2, 3 }, { 4, 5, 6 } }, d); } { double[] a = (double[])K.sum(x, axis: -1).eval(); Assert.AreEqual(new[] { 6.0, 15.0 }, a); double[] b = (double[])K.sum(x, axis: 0).eval(); Assert.AreEqual(new[] { 5.0, 7.0, 9.0 }, b); double[] c = (double[])K.sum(x, axis: 1).eval(); Assert.AreEqual(new[] { 6.0, 15.0 }, c); } } }