| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | # TensorFlow.NET | |
| 2 | - TensorFlow.NET provides .NET Standard binding for [TensorFlow](https://www.tensorflow.org/). | ||
| 2 | + TensorFlow.NET provides .NET Standard binding for [TensorFlow](https://www.tensorflow.org/). It's the full complete binding in CSharp language for TensorFlow API. It allows .NET developers to develop, train and deploy Machine Learning models in .NET standard which is running on cross-platform. | ||
| 3 | 3 | ||
| 4 | 4 | [](https://gitter.im/sci-sharp/community) | |
| 5 | 5 | [](https://ci.appveyor.com/project/Haiping-Chen/tensorflow-net) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,2 +1,23 @@ | |||
| 1 | 1 | # Chapter. Graph | |
| 2 | 2 | ||
| 3 | + 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. | ||
| 4 | + | ||
| 5 | + ### Defining the Graph | ||
| 6 | + | ||
| 7 | + 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. | ||
| 8 | + | ||
| 9 | + ```csharp | ||
| 10 | + with<Graph>(tf.Graph().as_default(), graph => | ||
| 11 | + { | ||
| 12 | + var variable = tf.Variable(31, name: "tree"); | ||
| 13 | + tf.global_variables_initializer(); | ||
| 14 | + variable.assign(12); | ||
| 15 | + }); | ||
| 16 | + ``` | ||
| 17 | + | ||
| 18 | + 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()`. | ||
| 19 | + | ||
| 20 | + A typical graph is looks like below: | ||
| 21 | + | ||
| 22 | +  | ||
| 23 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,2 +1,24 @@ | |||
| 1 | 1 | # Chapter. Session | |
| 2 | 2 | ||
| 3 | + TensorFlow **session** runs parts of the graph across a set of local and remote devices. A session allows to execute graphs or part of graphs. It allocates resources (on one or more machines) for that and holds the actual values of intermediate results and variables. | ||
| 4 | + | ||
| 5 | + ### Running Computations in a Session | ||
| 6 | + | ||
| 7 | + Let's complete the example in last chapter. | ||
| 8 | + | ||
| 9 | + ```csharp | ||
| 10 | + with<Graph>(tf.Graph(), graph => | ||
| 11 | + { | ||
| 12 | + var variable = tf.Variable(31, name: "tree"); | ||
| 13 | + var init = tf.global_variables_initializer(); | ||
| 14 | + | ||
| 15 | + var sess = tf.Session(graph); | ||
| 16 | + sess.run(init); | ||
| 17 | + | ||
| 18 | + var result = sess.run(variable); // 31 | ||
| 19 | + | ||
| 20 | + var assign = variable.assign(12); | ||
| 21 | + result = sess.run(assign); // 12 | ||
| 22 | + }); | ||
| 23 | + ``` | ||
| 24 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,8 +19,8 @@ Welcome to TensorFlow.NET's documentation! | |||
| 19 | 19 | Constant | |
| 20 | 20 | Variable | |
| 21 | 21 | Placeholder | |
| 22 | - Session | ||
| 23 | 22 | Graph | |
| 23 | + Session | ||
| 24 | 24 | Operation | |
| 25 | 25 | Attribute | |
| 26 | 26 | NameScope | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,10 @@ | |||
| 1 | 1 | Here are some pre-built TensorFlow binaries you can use for each platform: | |
| 2 | 2 | ||
| 3 | 3 | - Linux | |
| 4 | - - CPU-only: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.12.0.tar.gz | ||
| 5 | - - GPU-enabled: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-1.12.0.tar.gz | ||
| 6 | - - Mac: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-1.12.0.tar.gz | ||
| 7 | - - Windows: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.12.0.zip | ||
| 4 | + - CPU-only: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.13.1.tar.gz | ||
| 5 | + - GPU-enabled: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-1.13.1.tar.gz | ||
| 6 | + - Mac: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-1.13.1.tar.gz | ||
| 7 | + - Windows: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.13.1.zip | ||
| 8 | 8 | ||
| 9 | 9 | https://www.tensorflow.org/install/source_windows | |
| 10 | 10 | pacman -S git patch unzip | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,7 +47,27 @@ public void ScalarVar() | |||
| 47 | 47 | } | |
| 48 | 48 | ||
| 49 | 49 | [TestMethod] | |
| 50 | - public void Assign() | ||
| 50 | + public void Assign1() | ||
| 51 | + { | ||
| 52 | + with<Graph>(tf.Graph().as_default(), graph => | ||
| 53 | + { | ||
| 54 | + var variable = tf.Variable(31, name: "tree"); | ||
| 55 | + var init = tf.global_variables_initializer(); | ||
| 56 | + | ||
| 57 | + var sess = tf.Session(graph); | ||
| 58 | + sess.run(init); | ||
| 59 | + | ||
| 60 | + var result = sess.run(variable); | ||
| 61 | + Assert.IsTrue((int)result == 31); | ||
| 62 | + | ||
| 63 | + var assign = variable.assign(12); | ||
| 64 | + result = sess.run(assign); | ||
| 65 | + Assert.IsTrue((int)result == 12); | ||
| 66 | + }); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + [TestMethod] | ||
| 70 | + public void Assign2() | ||
| 51 | 71 | { | |
| 52 | 72 | var v1 = tf.Variable(10.0f, name: "v1"); //tf.get_variable("v1", shape: new TensorShape(3), initializer: tf.zeros_initializer); | |
| 53 | 73 | var inc_v1 = v1.assign(v1 + 1.0f); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments