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.cs 1.1 kB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Tensorflow;
  5. using TF_DataType = Tensorflow.DataType;
  6. namespace TensorFlowNET.Core
  7. {
  8. public class Operation
  9. {
  10. private Graph _graph;
  11. private IntPtr _c_op;
  12. public int _id => _id_value;
  13. private int _id_value;
  14. public string name;
  15. private Tensor[] _outputs;
  16. public Tensor[] outputs => _outputs;
  17. public Operation(NodeDef node_def, Graph g, object inputs = null, TF_DataType[] output_types = null, object control_inputs = null, TF_DataType[] input_types = null, string original_op = "", string op_def = "")
  18. {
  19. _graph = g;
  20. _id_value = _graph._next_id();
  21. _c_op = ops._create_c_op(g, node_def, inputs);
  22. var num_outputs = c_api.TF_OperationNumOutputs(_c_op);
  23. _outputs = new Tensor[num_outputs];
  24. for (int i = 0; i < num_outputs; i++)
  25. {
  26. _outputs[i] = new Tensor(this, i, TF_DataType.DtDouble);
  27. }
  28. _graph._add_op(this);
  29. }
  30. }
  31. }

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

Contributors (1)