Browse Source

update docs of Hello World sample

tags/v0.1.0-Tensor
Oceania2018 6 years ago
parent
commit
1344277eb4
10 changed files with 108 additions and 24 deletions
  1. +4
    -1
      README.md
  2. +16
    -0
      docs/README.md
  3. +16
    -7
      docs/source/FrontCover.md
  4. +60
    -4
      docs/source/HelloWorld.md
  5. +0
    -0
      docs/source/_static/front-cover.jpg
  6. BIN
      docs/source/_static/new-project-console.png
  7. BIN
      docs/source/_static/new-project.png
  8. +2
    -1
      docs/source/index.rst
  9. +10
    -8
      test/TensorFlowNET.Examples/HelloWorld.cs
  10. +0
    -3
      test/TensorFlowNET.Examples/Program.cs

+ 4
- 1
README.md View File

@@ -5,6 +5,7 @@ TensorFlow.NET provides .NET Standard binding for [TensorFlow](https://www.tenso
[![Tensorflow.NET](https://ci.appveyor.com/api/projects/status/wx4td43v2d3f2xj6?svg=true)](https://ci.appveyor.com/project/Haiping-Chen/tensorflow-net)
[![codecov](https://codecov.io/gh/SciSharp/NumSharp/branch/master/graph/badge.svg)](https://codecov.io/gh/SciSharp/NumSharp)
[![NuGet](https://img.shields.io/nuget/dt/TensorFlow.NET.svg)](https://www.nuget.org/packages/TensorFlow.NET)
[![Documentation Status](https://readthedocs.org/projects/tensorflownet/badge/?version=latest)](https://tensorflownet.readthedocs.io/en/latest/?badge=latest)

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

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

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

Star me or raise issue on [Github](https://github.com/SciSharp/TensorFlow.NET) feel free.

+ 16
- 0
docs/README.md View File

@@ -0,0 +1,16 @@
### Instll Sphinx
```cmd
pip install sphinx
pip install recommonmark
pip install sphinx_rtd_theme
```

### Init the docs
```cmd
sphinx-quickstarts
```

### Build the docs
```cmd
make html
```

+ 16
- 7
docs/source/FrontCover.md View File

@@ -9,7 +9,11 @@



![column-major order](_static/cover.jpg)
![Front Cover](_static/front-cover.jpg)







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

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

### 谷歌TensorFlow的C#封装库
### 谷歌TensorFlow的C#绑定库

#### 人人都可用的开源机器学习框架。




#### 开源机器学习框架。



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


<p style='float:right;'>
Haiping Chen & Christian Kahr<br/>
Christmas, 2018<br/>
陈海平 & 克里斯汀 卡尔<br/>
2018年圣诞节
<b>Haiping Chen & Christian Kahr</b><br/>
<b>Christmas, 2018</b><br/>
<b>陈海平 & 克里斯汀·卡尔</b><br/>
<b>2018年圣诞节</b>
</p>







+ 60
- 4
docs/source/HelloWorld.md View File

@@ -1,14 +1,70 @@
# Get started with TensorFlow.NET
# Get started with TensorFlow.NET

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

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.

### Install the TensorFlow.NET SDK
### Install the TensorFlow.NET SDK 安装开发环境

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.

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。

1. New a project

![New Project](_static/new-project.png)

2. Choose Console App (.NET Core)

![Console App](_static/new-project-console.png)


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

```cmd
PM> Install-Package TensorFlow.NET
```

### Start coding Hello World 开始编写Hello World

After installing the TensorFlow.NET package, you can use the `using Tensorflow` to introduce the TensorFlow library.

安装完TensorFlow.NET包后,你就可以使用`using Tensorflow`来引入TensorFlow库了。

```csharp
using System;
using Tensorflow;

namespace TensorFlowNET.Examples
{
/// <summary>
/// Simple hello world using TensorFlow
/// </summary>
public class HelloWorld : IExample
{
public void Run()
{
/* Create a Constant op
The op is added as a node to the default graph.
The value returned by the constructor represents the output
of the Constant op. */
var hello = tf.constant("Hello, TensorFlow!");

// Start tf session
using (var sess = tf.Session())
{
// Run the op
var result = sess.run(hello);
Console.WriteLine(result);
}
}
}
}
```
After CTRL + F5 run, you will get the output.
```cmd
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
Hello, TensorFlow!
Press any key to continue . . .
```


docs/source/_static/Cover.jpg → docs/source/_static/front-cover.jpg View File


BIN
docs/source/_static/new-project-console.png View File

Before After
Width: 1178  |  Height: 816  |  Size: 57 kB

BIN
docs/source/_static/new-project.png View File

Before After
Width: 1535  |  Height: 918  |  Size: 104 kB

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

@@ -25,4 +25,5 @@ Indices and tables
:maxdepth: 3
:caption: Get Started with TensorFlow.NET:

FrontCover
FrontCover
HelloWorld

+ 10
- 8
test/TensorFlowNET.Examples/HelloWorld.cs View File

@@ -13,18 +13,20 @@ namespace TensorFlowNET.Examples
{
public void Run()
{
/* # Create a Constant op
The op is added as a node to the default graph.
/* Create a Constant op
The op is added as a node to the default graph.
The value returned by the constructor represents the output
of the Constant op.*/
The value returned by the constructor represents the output
of the Constant op. */
var hello = tf.constant("Hello, TensorFlow!");

// Start tf session
var sess = tf.Session();

// Run the op
Console.WriteLine(sess.run(hello));
using (var sess = tf.Session())
{
// Run the op
var result = sess.run(hello);
Console.WriteLine(result);
}
}
}
}

+ 0
- 3
test/TensorFlowNET.Examples/Program.cs View File

@@ -20,11 +20,8 @@ namespace TensorFlowNET.Examples
catch (Exception ex)
{
Console.WriteLine(ex);
Console.ReadLine();
}
}

Console.ReadLine();
}
}
}

Loading…
Cancel
Save