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.

Randomize.Test.cs 1.0 kB

4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334353637
  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/1.20/reference/random/index.html
  12. /// </summary>
  13. [TestClass]
  14. public class RandomizeTest : EagerModeTestBase
  15. {
  16. [TestMethod]
  17. public void permutation()
  18. {
  19. var x = np.random.permutation(10);
  20. Assert.AreEqual(x.shape, 10);
  21. var y = np.random.permutation(x);
  22. Assert.AreEqual(x.shape, 10);
  23. Assert.AreNotEqual(x.ToArray<int>(), y.ToArray<int>());
  24. }
  25. /// <summary>
  26. /// https://numpy.org/doc/stable/reference/random/generated/numpy.random.normal.html
  27. /// </summary>
  28. [TestMethod]
  29. public void normal()
  30. {
  31. var x = np.random.normal(0, 0.1f, 1000);
  32. Equal(np.mean(x), 0f);
  33. }
  34. }
  35. }