Skip to content

Commit 8d47f40

Browse files
committed
update docs
1 parent ae5a109 commit 8d47f40

7 files changed

Lines changed: 70 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 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.
33

44
[![Join the chat at https://gitter.im/publiclab/publiclab](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sci-sharp/community)
55
[![Tensorflow.NET](https://ci.appveyor.com/api/projects/status/wx4td43v2d3f2xj6?svg=true)](https://ci.appveyor.com/project/Haiping-Chen/tensorflow-net)
3.25 MB
Loading

docs/source/Graph.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
11
# Chapter. Graph
22

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+
![image](../assets/graph_vis_animation.gif)
23+

docs/source/Session.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
11
# Chapter. Session
22

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+

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Welcome to TensorFlow.NET's documentation!
1919
Constant
2020
Variable
2121
Placeholder
22-
Session
2322
Graph
23+
Session
2424
Operation
2525
Attribute
2626
NameScope

tensorflowlib/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Here are some pre-built TensorFlow binaries you can use for each platform:
22

33
- 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
88

99
https://www.tensorflow.org/install/source_windows
1010
pacman -S git patch unzip

test/TensorFlowNET.UnitTest/VariableTest.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,27 @@ public void ScalarVar()
4747
}
4848

4949
[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()
5171
{
5272
var v1 = tf.Variable(10.0f, name: "v1"); //tf.get_variable("v1", shape: new TensorShape(3), initializer: tf.zeros_initializer);
5373
var inc_v1 = v1.assign(v1 + 1.0f);

0 commit comments

Comments
 (0)