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.

NameScopeTest.cs 1.4 kB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Tensorflow;
  6. using static Tensorflow.Python;
  7. namespace TensorFlowNET.UnitTest
  8. {
  9. [TestClass]
  10. public class NameScopeTest
  11. {
  12. Graph g = ops.get_default_graph();
  13. string name = "";
  14. [TestMethod]
  15. public void NestedNameScope()
  16. {
  17. with(new ops.NameScope("scope1"), scope1 =>
  18. {
  19. name = scope1;
  20. Assert.AreEqual("scope1", g._name_stack);
  21. Assert.AreEqual("scope1/", name);
  22. var const1 = tf.constant(1.0);
  23. Assert.AreEqual("scope1/Const:0", const1.name);
  24. with(new ops.NameScope("scope2"), scope2 =>
  25. {
  26. name = scope2;
  27. Assert.AreEqual("scope1/scope2", g._name_stack);
  28. Assert.AreEqual("scope1/scope2/", name);
  29. var const2 = tf.constant(2.0);
  30. Assert.AreEqual("scope1/scope2/Const:0", const2.name);
  31. });
  32. Assert.AreEqual("scope1", g._name_stack);
  33. var const3 = tf.constant(2.0);
  34. Assert.AreEqual("scope1/Const_1:0", const3.name);
  35. });
  36. Assert.AreEqual("", g._name_stack);
  37. }
  38. }
  39. }