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.

Graph.md 1.1 kB

6 years ago
1234567891011121314151617181920212223
  1. # Chapter. Graph
  2. TensorFlow uses a **dataflow graph** to represent your computation in terms of the dependencies between individual operations. A graph defines the computation. It doesn't compute anything, it doesn't hold any values, it just defines the operations that you specified in your code.
  3. ### Defining the Graph
  4. We define a graph with a variable and three operations: `variable` returns the current value of our variable. `initialize` assigns the initial value of 31 to that variable. `assign` assigns the new value of 12 to that variable.
  5. ```csharp
  6. with<Graph>(tf.Graph().as_default(), graph =>
  7. {
  8. var variable = tf.Variable(31, name: "tree");
  9. tf.global_variables_initializer();
  10. variable.assign(12);
  11. });
  12. ```
  13. TF.NET simulate a `with` syntax to manage the Graph lifecycle which will be disposed when the graph instance is no long need. The graph is also what the sessions in the next chapter use when not manually specifying a graph because use invoked the `as_default()`.
  14. A typical graph is looks like below:
  15. ![image](../assets/graph_vis_animation.gif)

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