Browse Source

add ReduceSum test.

tags/v0.20
Oceania2018 5 years ago
parent
commit
17204b55f2
6 changed files with 26 additions and 5 deletions
  1. +1
    -1
      test/TensorFlowNET.UnitTest/TF_API/GradientTest.cs
  2. +1
    -1
      test/TensorFlowNET.UnitTest/TF_API/LinalgTest.cs
  3. +20
    -0
      test/TensorFlowNET.UnitTest/TF_API/MathApiTest.cs
  4. +2
    -1
      test/TensorFlowNET.UnitTest/TF_API/StringsApiTest.cs
  5. +1
    -1
      test/TensorFlowNET.UnitTest/TF_API/TensorOperate.cs
  6. +1
    -1
      test/TensorFlowNET.UnitTest/Utilities/TestHelper.cs

+ 1
- 1
test/TensorFlowNET.UnitTest/TF_API/GradientTest.cs View File

@@ -5,7 +5,7 @@ using System.Linq;
using Tensorflow;
using static Tensorflow.Binding;

namespace Tensorflow.UnitTest.TF_API
namespace TensorFlowNET.UnitTest.TF_API
{
[TestClass]
public class GradientTest


+ 1
- 1
test/TensorFlowNET.UnitTest/TF_API/LinalgTest.cs View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Text;
using static Tensorflow.Binding;

namespace Tensorflow.UnitTest.TF_API
namespace TensorFlowNET.UnitTest.TF_API
{
[TestClass]
public class LinalgTest


+ 20
- 0
test/TensorFlowNET.UnitTest/TF_API/MathApiTest.cs View File

@@ -13,6 +13,7 @@ namespace TensorFlowNET.UnitTest.TF_API
{
// A constant vector of size 6
Tensor a = tf.constant(new float[] { 1.0f, -0.5f, 3.4f, -2.1f, 0.0f, -6.5f });
Tensor b = tf.constant(new float[,] { { 1.0f, -0.5f, 3.4f }, { -2.1f, 0.0f, -6.5f } });

[TestMethod]
public void Sin()
@@ -31,5 +32,24 @@ namespace TensorFlowNET.UnitTest.TF_API
var actual = b.ToArray<float>();
Assert.IsTrue(Equal(expected, actual));
}

[TestMethod]
public void ReduceSum()
{
var x1 = tf.reduce_sum(b);
Assert.AreEqual(-4.7f, (float)x1);

var x2 = tf.reduce_sum(b, 0);
Assert.IsTrue(Enumerable.SequenceEqual(new[] { -1.0999999f, -0.5f, -3.1f }, x2.ToArray<float>()));

var x3 = tf.reduce_sum(b, 1);
Assert.IsTrue(Enumerable.SequenceEqual(new[] { 3.9f, -8.6f }, x3.ToArray<float>()));

var x4 = tf.reduce_sum(b, 1, keepdims: true);
Assert.AreEqual((2, 1), x4.TensorShape);

var x5 = tf.reduce_sum(b, (0, 1));
Assert.AreEqual(-4.7f, (float)x5);
}
}
}

+ 2
- 1
test/TensorFlowNET.UnitTest/TF_API/StringsApiTest.cs View File

@@ -2,9 +2,10 @@
using System;
using System.Collections.Generic;
using System.Text;
using Tensorflow;
using static Tensorflow.Binding;

namespace Tensorflow.UnitTest.TF_API
namespace TensorFlowNET.UnitTest.TF_API
{
[TestClass]
public class StringsApiTest


+ 1
- 1
test/TensorFlowNET.UnitTest/TF_API/TensorOperate.cs View File

@@ -5,7 +5,7 @@ using System.Linq;
using Tensorflow;
using static Tensorflow.Binding;

namespace Tensorflow.UnitTest.TF_API
namespace TensorFlowNET.UnitTest.TF_API
{
[TestClass]
public class TensorOperate


+ 1
- 1
test/TensorFlowNET.UnitTest/Utilities/TestHelper.cs View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Tensorflow.UnitTest
namespace TensorFlowNET.UnitTest
{
public class TestHelper
{


Loading…
Cancel
Save