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.

WhileContextTestCase.cs 1.7 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using Tensorflow;
  4. using static Tensorflow.Python;
  5. namespace TensorFlowNET.UnitTest.control_flow_ops_test
  6. {
  7. [TestClass]
  8. public class WhileContextTestCase : PythonTest
  9. {
  10. private void _testWhileContextHelper(int? maximum_iterations = null)
  11. {
  12. // TODO: implement missing code dependencies
  13. using (var sess = this.cached_session())
  14. {
  15. var i = constant_op.constant(0, name: "i");
  16. var c = new Func<Tensor, Tensor>(x => gen_math_ops.less(x, 10, name: "c"));
  17. var b = new Func<Tensor, Tensor>(x => gen_math_ops.add(x, 1, name: "c"));
  18. control_flow_ops.while_loop(
  19. c, b, new[] { i }, maximum_iterations);
  20. foreach (Operation op in sess.graph.get_operations())
  21. {
  22. var control_flow_context = op._get_control_flow_context();
  23. /*if (control_flow_context != null)
  24. self.assertProtoEquals(control_flow_context.to_proto(),
  25. WhileContext.from_proto(
  26. control_flow_context.to_proto()).to_proto(), "");*/
  27. }
  28. }
  29. }
  30. [Ignore("TODO")]
  31. [TestMethod]
  32. public void testWhileContext()
  33. {
  34. _testWhileContextHelper();
  35. }
  36. [Ignore("TODO")]
  37. [TestMethod]
  38. public void testWhileContextWithMaximumIterations()
  39. {
  40. _testWhileContextHelper(maximum_iterations: 10);
  41. }
  42. }
  43. }