Skip to content

Commit 1344277

Browse files
committed
update docs of Hello World sample
1 parent 1956cf9 commit 1344277

10 files changed

Lines changed: 108 additions & 24 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ TensorFlow.NET provides .NET Standard binding for [TensorFlow](https://www.tenso
55
[![Tensorflow.NET](https://ci.appveyor.com/api/projects/status/wx4td43v2d3f2xj6?svg=true)](https://ci.appveyor.com/project/Haiping-Chen/tensorflow-net)
66
[![codecov](https://codecov.io/gh/SciSharp/NumSharp/branch/master/graph/badge.svg)](https://codecov.io/gh/SciSharp/NumSharp)
77
[![NuGet](https://img.shields.io/nuget/dt/TensorFlow.NET.svg)](https://www.nuget.org/packages/TensorFlow.NET)
8+
[![Documentation Status](https://readthedocs.org/projects/tensorflownet/badge/?version=latest)](https://tensorflownet.readthedocs.io/en/latest/?badge=latest)
89

910
TensorFlow.NET is a member project of [SciSharp](https://github.com/SciSharp) stack.
1011

@@ -54,4 +55,6 @@ using(var sess = tf.Session())
5455
}
5556
```
5657

57-
Star me or raise issue on [Github](https://github.com/SciSharp/TensorFlow.NET) feel free.
58+
Read the docs & book [The Definitive Guide to Tensorflow.NET](https://tensorflownet.readthedocs.io/en/latest/FrontCover.html).
59+
60+
Star me or raise issue on [Github](https://github.com/SciSharp/TensorFlow.NET) feel free.

docs/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### Instll Sphinx
2+
```cmd
3+
pip install sphinx
4+
pip install recommonmark
5+
pip install sphinx_rtd_theme
6+
```
7+
8+
### Init the docs
9+
```cmd
10+
sphinx-quickstarts
11+
```
12+
13+
### Build the docs
14+
```cmd
15+
make html
16+
```

docs/source/FrontCover.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010

1111

12-
![column-major order](_static/cover.jpg)
12+
![Front Cover](_static/front-cover.jpg)
13+
14+
15+
16+
1317

1418

1519

@@ -19,9 +23,13 @@
1923

2024
#### An Open Source Machine Learning Framework for Everyone
2125

22-
### 谷歌TensorFlow的C#封装库
26+
### 谷歌TensorFlow的C#绑定库
27+
28+
#### 人人都可用的开源机器学习框架。
29+
30+
31+
2332

24-
#### 开源机器学习框架。
2533

2634

2735

@@ -30,13 +38,14 @@
3038

3139

3240
<p style='float:right;'>
33-
Haiping Chen & Christian Kahr<br/>
34-
Christmas, 2018<br/>
35-
陈海平 & 克里斯汀 卡尔<br/>
36-
2018年圣诞节
41+
<b>Haiping Chen & Christian Kahr</b><br/>
42+
<b>Christmas, 2018</b><br/>
43+
<b>陈海平 & 克里斯汀·卡尔</b><br/>
44+
<b>2018年圣诞节</b>
3745
</p>
3846

3947

4048

4149

4250

51+

docs/source/HelloWorld.md

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,70 @@
1-
# Get started with TensorFlow.NET
1+
# Get started with TensorFlow.NET
22

3-
让我们先运行一个经典的HelloWorld程序,看看TensorFlow是在.NET上面运行的效果,我想不出有比做个HelloWorld再简单的方式了
3+
让我们先运行一个经典的HelloWorld程序,看看TensorFlow在.NET上面运行的效果,我想不出有比做个HelloWorld更简单的方式了
44

55
Let's run a classic HelloWorld program first and see if TensorFlow is running on .NET. I can't think of a simpler way to be a HelloWorld.
66

7-
### Install the TensorFlow.NET SDK
7+
### Install the TensorFlow.NET SDK 安装开发环境
8+
9+
TensorFlow.NET uses the .NET Standard 2.0 standard, so your new project Target Framework can be .NET Framework or .NET Core. All the examples in this book are using .NET Core 2.2 and Microsoft Visual Studio Community 2017. To start building TensorFlow program you just need to download and install the .NET SDK (Software Development Kit). You have to download the latest .NET Core SDK from offical website: https://dotnet.microsoft.com/download.
10+
11+
TensorFlow.NET采用.NET标准库2.0版本,因此你的新建工程可以是.NET Framework或者是基于.NET Core的。本文中的所有例子都是用的.NET Core 2.2的,IDE用的是Microsoft Visual Studio Community 2017。为了能编译和运行TensorFlow工程,你需要从这里下载最新的.NET Core SDK: https://dotnet.microsoft.com/download。
12+
13+
1. New a project
14+
15+
![New Project](_static/new-project.png)
16+
17+
2. Choose Console App (.NET Core)
18+
19+
![Console App](_static/new-project-console.png)
20+
821

9-
To start building TensorFlow program you just need to download and install the .NET SDK (Software Development Kit).
1022

1123
```cmd
1224
PM> Install-Package TensorFlow.NET
1325
```
1426

27+
### Start coding Hello World 开始编写Hello World
28+
29+
After installing the TensorFlow.NET package, you can use the `using Tensorflow` to introduce the TensorFlow library.
30+
31+
安装完TensorFlow.NET包后,你就可以使用`using Tensorflow`来引入TensorFlow库了。
32+
33+
```csharp
34+
using System;
35+
using Tensorflow;
36+
37+
namespace TensorFlowNET.Examples
38+
{
39+
/// <summary>
40+
/// Simple hello world using TensorFlow
41+
/// </summary>
42+
public class HelloWorld : IExample
43+
{
44+
public void Run()
45+
{
46+
/* Create a Constant op
47+
The op is added as a node to the default graph.
48+
49+
The value returned by the constructor represents the output
50+
of the Constant op. */
51+
var hello = tf.constant("Hello, TensorFlow!");
52+
53+
// Start tf session
54+
using (var sess = tf.Session())
55+
{
56+
// Run the op
57+
var result = sess.run(hello);
58+
Console.WriteLine(result);
59+
}
60+
}
61+
}
62+
}
63+
```
64+
After CTRL + F5 run, you will get the output.
65+
```cmd
66+
2019-01-05 10:53:42.145931: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
67+
Hello, TensorFlow!
68+
Press any key to continue . . .
69+
```
70+
56 KB
Loading
101 KB
Loading

docs/source/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ Indices and tables
2525
:maxdepth: 3
2626
:caption: Get Started with TensorFlow.NET:
2727

28-
FrontCover
28+
FrontCover
29+
HelloWorld

test/TensorFlowNET.Examples/HelloWorld.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ public class HelloWorld : IExample
1313
{
1414
public void Run()
1515
{
16-
/* # Create a Constant op
17-
The op is added as a node to the default graph.
16+
/* Create a Constant op
17+
The op is added as a node to the default graph.
1818
19-
The value returned by the constructor represents the output
20-
of the Constant op.*/
19+
The value returned by the constructor represents the output
20+
of the Constant op. */
2121
var hello = tf.constant("Hello, TensorFlow!");
2222

2323
// Start tf session
24-
var sess = tf.Session();
25-
26-
// Run the op
27-
Console.WriteLine(sess.run(hello));
24+
using (var sess = tf.Session())
25+
{
26+
// Run the op
27+
var result = sess.run(hello);
28+
Console.WriteLine(result);
29+
}
2830
}
2931
}
3032
}

test/TensorFlowNET.Examples/Program.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ static void Main(string[] args)
2020
catch (Exception ex)
2121
{
2222
Console.WriteLine(ex);
23-
Console.ReadLine();
2423
}
2524
}
26-
27-
Console.ReadLine();
2825
}
2926
}
3027
}

0 commit comments

Comments
 (0)