Browse Source

update docs

tags/v0.8.0
haiping008 6 years ago
parent
commit
8d47f40cea
7 changed files with 70 additions and 7 deletions
  1. +1
    -1
      README.md
  2. BIN
      docs/assets/graph_vis_animation.gif
  3. +21
    -0
      docs/source/Graph.md
  4. +22
    -0
      docs/source/Session.md
  5. +1
    -1
      docs/source/index.rst
  6. +4
    -4
      tensorflowlib/README.md
  7. +21
    -1
      test/TensorFlowNET.UnitTest/VariableTest.cs

+ 1
- 1
README.md View File

@@ -1,5 +1,5 @@
# TensorFlow.NET
TensorFlow.NET provides .NET Standard binding for [TensorFlow](https://www.tensorflow.org/).
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.

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


BIN
docs/assets/graph_vis_animation.gif View File

Before After
Width: 1300  |  Height: 680  |  Size: 3.4 MB

+ 21
- 0
docs/source/Graph.md View File

@@ -1,2 +1,23 @@
# Chapter. Graph

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.

### Defining the Graph

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.

```csharp
with<Graph>(tf.Graph().as_default(), graph =>
{
var variable = tf.Variable(31, name: "tree");
tf.global_variables_initializer();
variable.assign(12);
});
```

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()`.

A typical graph is looks like below:

![image](../assets/graph_vis_animation.gif)


+ 22
- 0
docs/source/Session.md View File

@@ -1,2 +1,24 @@
# Chapter. Session

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.

### Running Computations in a Session

Let's complete the example in last chapter.

```csharp
with<Graph>(tf.Graph(), graph =>
{
var variable = tf.Variable(31, name: "tree");
var init = tf.global_variables_initializer();

var sess = tf.Session(graph);
sess.run(init);

var result = sess.run(variable); // 31

var assign = variable.assign(12);
result = sess.run(assign); // 12
});
```


+ 1
- 1
docs/source/index.rst View File

@@ -19,8 +19,8 @@ Welcome to TensorFlow.NET's documentation!
Constant
Variable
Placeholder
Session
Graph
Session
Operation
Attribute
NameScope


+ 4
- 4
tensorflowlib/README.md View File

@@ -1,10 +1,10 @@
Here are some pre-built TensorFlow binaries you can use for each platform:

- Linux
- CPU-only: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.12.0.tar.gz
- GPU-enabled: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-1.12.0.tar.gz
- Mac: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-1.12.0.tar.gz
- Windows: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.12.0.zip
- CPU-only: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.13.1.tar.gz
- GPU-enabled: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-1.13.1.tar.gz
- Mac: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-1.13.1.tar.gz
- Windows: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.13.1.zip

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


+ 21
- 1
test/TensorFlowNET.UnitTest/VariableTest.cs View File

@@ -47,7 +47,27 @@ namespace TensorFlowNET.UnitTest
}

[TestMethod]
public void Assign()
public void Assign1()
{
with<Graph>(tf.Graph().as_default(), graph =>
{
var variable = tf.Variable(31, name: "tree");
var init = tf.global_variables_initializer();

var sess = tf.Session(graph);
sess.run(init);

var result = sess.run(variable);
Assert.IsTrue((int)result == 31);

var assign = variable.assign(12);
result = sess.run(assign);
Assert.IsTrue((int)result == 12);
});
}

[TestMethod]
public void Assign2()
{
var v1 = tf.Variable(10.0f, name: "v1"); //tf.get_variable("v1", shape: new TensorShape(3), initializer: tf.zeros_initializer);
var inc_v1 = v1.assign(v1 + 1.0f);


Loading…
Cancel
Save