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.

Manipulation.Test.cs 1.1 kB

4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  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.array-manipulation.html
  12. /// </summary>
  13. [TestClass]
  14. public class ManipulationTest : EagerModeTestBase
  15. {
  16. [TestMethod]
  17. public void expand_dims()
  18. {
  19. var x = np.array(new[] { 1, 2 });
  20. var y = np.expand_dims(x, axis: 0);
  21. Assert.AreEqual(y.shape, (1, 2));
  22. y = np.expand_dims(x, axis: 1);
  23. Assert.AreEqual(y.shape, (2, 1));
  24. }
  25. [TestMethod]
  26. public void moveaxis()
  27. {
  28. var x = np.zeros((3, 4, 5));
  29. var y = np.moveaxis(x, 0, -1);
  30. Assert.AreEqual(y.shape, (4, 5, 3));
  31. y = np.moveaxis(x, (0, 1), (-1, -2));
  32. Assert.AreEqual(y.shape, (5, 4, 3));
  33. y = np.moveaxis(x, (0, 1, 2), (-1, -2, -3));
  34. Assert.AreEqual(y.shape, (5, 4, 3));
  35. }
  36. }
  37. }