| @@ -5,6 +5,7 @@ TensorFlow.NET provides .NET Standard binding for [TensorFlow](https://www.tenso | |||||
| [](https://ci.appveyor.com/project/Haiping-Chen/tensorflow-net) | [](https://ci.appveyor.com/project/Haiping-Chen/tensorflow-net) | ||||
| [](https://codecov.io/gh/SciSharp/NumSharp) | [](https://codecov.io/gh/SciSharp/NumSharp) | ||||
| [](https://www.nuget.org/packages/TensorFlow.NET) | [](https://www.nuget.org/packages/TensorFlow.NET) | ||||
| [](https://tensorflownet.readthedocs.io/en/latest/?badge=latest) | |||||
| TensorFlow.NET is a member project of [SciSharp](https://github.com/SciSharp) stack. | 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. | |||||
| @@ -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 | |||||
| ``` | |||||
| @@ -9,7 +9,11 @@ | |||||
|  | |||||
|  | |||||
| @@ -19,9 +23,13 @@ | |||||
| #### An Open Source Machine Learning Framework for Everyone | #### An Open Source Machine Learning Framework for Everyone | ||||
| ### 谷歌TensorFlow的C#封装库 | |||||
| ### 谷歌TensorFlow的C#绑定库 | |||||
| #### 人人都可用的开源机器学习框架。 | |||||
| #### 开源机器学习框架。 | |||||
| @@ -30,13 +38,14 @@ | |||||
| <p style='float:right;'> | <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> | </p> | ||||
| @@ -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. | 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 | |||||
|  | |||||
| 2. Choose Console App (.NET Core) | |||||
|  | |||||
| To start building TensorFlow program you just need to download and install the .NET SDK (Software Development Kit). | |||||
| ```cmd | ```cmd | ||||
| PM> Install-Package TensorFlow.NET | 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 . . . | |||||
| ``` | |||||
| @@ -25,4 +25,5 @@ Indices and tables | |||||
| :maxdepth: 3 | :maxdepth: 3 | ||||
| :caption: Get Started with TensorFlow.NET: | :caption: Get Started with TensorFlow.NET: | ||||
| FrontCover | |||||
| FrontCover | |||||
| HelloWorld | |||||
| @@ -13,18 +13,20 @@ namespace TensorFlowNET.Examples | |||||
| { | { | ||||
| public void Run() | 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!"); | var hello = tf.constant("Hello, TensorFlow!"); | ||||
| // Start tf session | // 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); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -20,11 +20,8 @@ namespace TensorFlowNET.Examples | |||||
| catch (Exception ex) | catch (Exception ex) | ||||
| { | { | ||||
| Console.WriteLine(ex); | Console.WriteLine(ex); | ||||
| Console.ReadLine(); | |||||
| } | } | ||||
| } | } | ||||
| Console.ReadLine(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||