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.

TensorShapeTest.cs 1.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using NumSharp;
  4. using Tensorflow;
  5. using static Tensorflow.Binding;
  6. namespace TensorFlowNET.UnitTest
  7. {
  8. [TestClass]
  9. public class TensorShapeTest
  10. {
  11. [TestMethod]
  12. public void Case1()
  13. {
  14. int a = 2;
  15. int b = 3;
  16. var dims = new [] { Unknown, a, b};
  17. new TensorShape(dims).GetPrivate<Shape>("shape").Should().BeShaped(-1, 2, 3);
  18. }
  19. [TestMethod]
  20. public void Case2()
  21. {
  22. int a = 2;
  23. int b = 3;
  24. var dims = new[] { Unknown, a, b};
  25. new TensorShape(new [] {dims}).GetPrivate<Shape>("shape").Should().BeShaped(-1, 2, 3);
  26. }
  27. [TestMethod]
  28. public void Case3()
  29. {
  30. int a = 2;
  31. int b = Unknown;
  32. var dims = new [] { Unknown, a, b};
  33. new TensorShape(new [] {dims}).GetPrivate<Shape>("shape").Should().BeShaped(-1, 2, -1);
  34. }
  35. [TestMethod]
  36. public void Case4()
  37. {
  38. TensorShape shape = (Unknown, Unknown);
  39. shape.GetPrivate<Shape>("shape").Should().BeShaped(-1, -1);
  40. }
  41. [TestMethod]
  42. public void Case5()
  43. {
  44. TensorShape shape = (1, Unknown, 3);
  45. shape.GetPrivate<Shape>("shape").Should().BeShaped(1, -1, 3);
  46. }
  47. [TestMethod]
  48. public void Case6()
  49. {
  50. TensorShape shape = (Unknown, 1, 2, 3, Unknown);
  51. shape.GetPrivate<Shape>("shape").Should().BeShaped(-1, 1, 2, 3, -1);
  52. }
  53. }
  54. }