You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

MathOperationTest.cs 1.1 kB

1234567891011121314151617181920212223242526272829303132333435
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using Tensorflow;
  7. using static Tensorflow.Binding;
  8. namespace TensorFlowNET.UnitTest.math_test
  9. {
  10. [TestClass]
  11. public class MathOperationTest : TFNetApiTest
  12. {
  13. // A constant vector of size 6
  14. Tensor a = tf.constant(new float[] { 1.0f, -0.5f, 3.4f, -2.1f, 0.0f, -6.5f });
  15. [TestMethod]
  16. public void Sin()
  17. {
  18. var b = tf.sin(a, name: "Sin");
  19. var expected = new float[] { 0.84147096f, -0.47942555f, -0.2555412f, -0.86320937f, 0f, -0.21511999f };
  20. var actual = b.ToArray<float>();
  21. Assert.IsTrue(Equal(expected, actual));
  22. }
  23. [TestMethod]
  24. public void Tan()
  25. {
  26. var b = tf.tan(a, name: "Tan");
  27. var expected = new float[] { 1.5574077f, -0.5463025f, 0.264317f, 1.709847f, 0f, -0.2202772f };
  28. var actual = b.ToArray<float>();
  29. Assert.IsTrue(Equal(expected, actual));
  30. }
  31. }
  32. }