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.

Statistics.Test.cs 945 B

3 years ago
1234567891011121314151617181920212223242526272829303132
  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 Tensorflow.NumPy;
  8. namespace TensorFlowNET.UnitTest.NumPy
  9. {
  10. /// <summary>
  11. /// https://numpy.org/doc/stable/reference/routines.statistics.html
  12. /// </summary>
  13. [TestClass]
  14. public class StatisticsTest : EagerModeTestBase
  15. {
  16. [TestMethod]
  17. public void average()
  18. {
  19. var data = np.arange(1, 5);
  20. var avg = np.average(data);
  21. Assert.AreEqual(avg, 2.5);
  22. data = np.arange(6).reshape((3, 2));
  23. avg = np.average(data, axis: 1);
  24. assertAllEqual(avg.ToArray<double>(), new[] { 0.5, 2.5, 4.5 });
  25. // avg = np.average(data, axis: 1, weights: new[] { 1.0 / 4, 3.0 / 4 });
  26. // assertAllEqual(avg.ToArray<double>(), new[] { 0.75, 2.75, 4.75 });
  27. }
  28. }
  29. }