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.

Operation.Control.cs 1.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Tensorflow.Operations;
  5. namespace Tensorflow
  6. {
  7. public partial class Operation
  8. {
  9. private IControlFlowContext _control_flow_context;
  10. /// <summary>
  11. /// Add this op to its control flow context.
  12. ///
  13. /// This may add new ops and change this op's inputs. self.inputs must be
  14. /// available before calling this method.
  15. /// </summary>
  16. public void _control_flow_post_processing()
  17. {
  18. foreach(var input_tensor in inputs)
  19. {
  20. //TODO: implement below code dependency
  21. //control_flow_util.CheckInputFromValidContext(this, input_tensor.op);
  22. }
  23. if (_control_flow_context != null)
  24. _control_flow_context.AddOp(this);
  25. }
  26. public void _add_control_input(Operation op)
  27. {
  28. c_api.TF_AddControlInput(_operDesc, op);
  29. }
  30. public void _add_control_inputs(Operation[] ops)
  31. {
  32. foreach (var op in ops)
  33. _add_control_input(op);
  34. }
  35. public void _set_control_flow_context(IControlFlowContext ctx)
  36. {
  37. _control_flow_context = ctx;
  38. }
  39. public IControlFlowContext _get_control_flow_context()
  40. {
  41. return _control_flow_context;
  42. }
  43. }
  44. }

tensorflow框架的.NET版本,提供了丰富的特性和API,可以借此很方便地在.NET平台下搭建深度学习训练与推理流程。