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.8 kB

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