Targets { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Code in TensorFlow.NET Practice/YoloV3_train/YoloV3_train/Core/Common.cs:
--------------------------------------------------------------------------------
1 | using Tensorflow;
2 | using static Tensorflow.Binding;
3 | using static Tensorflow.KerasApi;
4 |
5 | namespace YoloV3_train.Core
6 | {
7 | class Common
8 | {
9 | public static Tensor convolutional(Tensor input_layer, TensorShape filters_shape,
10 | bool downsample = false, bool activate = true,
11 | bool bn = true)
12 | {
13 | int strides;
14 | string padding;
15 |
16 | if (downsample)
17 | {
18 | var zero_padding_2d = keras.layers.ZeroPadding2D(new[,] { { 1, 0 }, { 1, 0 } });
19 | input_layer = zero_padding_2d.Apply(input_layer);
20 | strides = 2;
21 | padding = "valid";
22 | }
23 | else
24 | {
25 | strides = 1;
26 | padding = "same";
27 | }
28 |
29 | var conv2d_layer = keras.layers.Conv2D(filters_shape[-1],
30 | kernel_size: filters_shape[0],
31 | strides: strides,
32 | padding: padding,
33 | use_bias: !bn,
34 | kernel_regularizer: keras.regularizers.l2(0.0005f),
35 | kernel_initializer: tf.random_normal_initializer(stddev: 0.01f),
36 | bias_initializer: tf.constant_initializer(0f));
37 | var conv = conv2d_layer.Apply(input_layer);
38 | if (bn)
39 | {
40 | var batch_layer = keras.layers.BatchNormalization();
41 | conv = batch_layer.Apply(conv);
42 | }
43 |
44 | if (activate)
45 | conv = keras.layers.LeakyReLU(alpha: 0.1f).Apply(conv);
46 |
47 | return conv;
48 | }
49 |
50 | public static Tensor upsample(Tensor input_layer)
51 | {
52 | return keras.layers.UpSampling2D(size: (2, 2), interpolation: "nearest")
53 | .Apply(input_layer);
54 | }
55 |
56 | public static Tensor residual_block(Tensor input_layer,
57 | int input_channel, int filter_num1, int filter_num2)
58 | {
59 | var short_cut = input_layer;
60 |
61 | var conv = convolutional(input_layer, (1, 1, input_channel, filter_num1));
62 | conv = convolutional(conv, (3, 3, filter_num1, filter_num2));
63 |
64 | var residual_output = keras.layers.Add().Apply(new[] { short_cut, conv });
65 |
66 | return residual_output;
67 | }
68 |
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Code in TensorFlow.NET Practice/YoloV3_train/YoloV3_train/Core/LabelBorderBox.cs:
--------------------------------------------------------------------------------
1 | using NumSharp;
2 |
3 | namespace YoloV3_train.Core
4 | {
5 | class LabelBorderBox
6 | {
7 | public NDArray Label { get; set; }
8 | public NDArray BorderBox { get; set; }
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Code in TensorFlow.NET Practice/YoloV3_train/YoloV3_train/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace YoloV3_train
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | var yolo3 = new SampleYOLOv3();
10 | yolo3.Run();
11 |
12 | Console.WriteLine("YOLOv3 is completed.");
13 | Console.ReadLine();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Code in TensorFlow.NET Practice/YoloV3_train/YoloV3_train/YoloV3_train.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 | x64
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Code in TensorFlow.NET Practice/YoloV3_train/YoloV3_train/obj/YoloV3_train.csproj.nuget.g.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | True
5 | NuGet
6 | $(MSBuildThisFileDirectory)project.assets.json
7 | $(UserProfile)\.nuget\packages\
8 | C:\Users\Administrator\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files (x86)\Microsoft\Xamarin\NuGet\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder
9 | PackageReference
10 | 5.9.1
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Code in TensorFlow.NET Practice/YoloV3_train/YoloV3_train/obj/YoloV3_train.csproj.nuget.g.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 |
6 |
--------------------------------------------------------------------------------
/Code in TensorFlow.NET Practice/word2vec/word2vec.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31205.134
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "word2vec", "word2vec\word2vec.csproj", "{909E5EFB-534E-4409-830E-7C97A509B583}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {909E5EFB-534E-4409-830E-7C97A509B583}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {909E5EFB-534E-4409-830E-7C97A509B583}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {909E5EFB-534E-4409-830E-7C97A509B583}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {909E5EFB-534E-4409-830E-7C97A509B583}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {6A87B967-FF2A-4FC4-9C03-76AF84C6117A}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Code in TensorFlow.NET Practice/word2vec/word2vec/obj/word2vec.csproj.nuget.dgspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "format": 1,
3 | "restore": {
4 | "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\word2vec\\word2vec\\word2vec.csproj": {}
5 | },
6 | "projects": {
7 | "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\word2vec\\word2vec\\word2vec.csproj": {
8 | "version": "1.0.0",
9 | "restore": {
10 | "projectUniqueName": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\word2vec\\word2vec\\word2vec.csproj",
11 | "projectName": "word2vec",
12 | "projectPath": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\word2vec\\word2vec\\word2vec.csproj",
13 | "packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\",
14 | "outputPath": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\word2vec\\word2vec\\obj\\",
15 | "projectStyle": "PackageReference",
16 | "fallbackFolders": [
17 | "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
18 | "C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\",
19 | "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
20 | ],
21 | "configFilePaths": [
22 | "C:\\Users\\Administrator\\AppData\\Roaming\\NuGet\\NuGet.Config",
23 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
24 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config",
25 | "C:\\Program Files (x86)\\NuGet\\Config\\Xamarin.Offline.config"
26 | ],
27 | "originalTargetFrameworks": [
28 | "net5.0"
29 | ],
30 | "sources": {
31 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
32 | "C:\\Users\\Administrator\\Desktop": {},
33 | "https://api.nuget.org/v3/index.json": {}
34 | },
35 | "frameworks": {
36 | "net5.0": {
37 | "targetAlias": "net5.0",
38 | "projectReferences": {}
39 | }
40 | },
41 | "warningProperties": {
42 | "warnAsError": [
43 | "NU1605"
44 | ]
45 | }
46 | },
47 | "frameworks": {
48 | "net5.0": {
49 | "targetAlias": "net5.0",
50 | "dependencies": {
51 | "SciSharp.TensorFlow.Redist": {
52 | "target": "Package",
53 | "version": "[2.4.1, )"
54 | },
55 | "TensorFlow.Keras": {
56 | "target": "Package",
57 | "version": "[0.5.1, )"
58 | }
59 | },
60 | "imports": [
61 | "net461",
62 | "net462",
63 | "net47",
64 | "net471",
65 | "net472",
66 | "net48"
67 | ],
68 | "assetTargetFallback": true,
69 | "warn": true,
70 | "frameworkReferences": {
71 | "Microsoft.NETCore.App": {
72 | "privateAssets": "all"
73 | }
74 | },
75 | "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.301\\RuntimeIdentifierGraph.json"
76 | }
77 | }
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/Code in TensorFlow.NET Practice/word2vec/word2vec/obj/word2vec.csproj.nuget.g.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | True
5 | NuGet
6 | $(MSBuildThisFileDirectory)project.assets.json
7 | $(UserProfile)\.nuget\packages\
8 | C:\Users\Administrator\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files (x86)\Microsoft\Xamarin\NuGet\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder
9 | PackageReference
10 | 5.10.0
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Code in TensorFlow.NET Practice/word2vec/word2vec/obj/word2vec.csproj.nuget.g.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 |
6 |
--------------------------------------------------------------------------------
/Code in TensorFlow.NET Practice/word2vec/word2vec/word2vec.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Documentations for TensorFlow.NET
2 |
3 | This site is built with [Docsify](https://docsify.js.org/). Site content is written in Markdown format located in [docs](docs/).
4 |
5 | ## Developing
6 |
7 | 1. Clone the repository:
8 |
9 | ```
10 | git clone https://github.com/SciSharp/tensorflow-net-docs.git
11 | ```
12 |
13 | 1. Install docsify:
14 |
15 | ```
16 | npm i docsify-cli -g
17 | ```
18 |
19 | 1. Host a local environment:
20 |
21 | ```
22 | docsify serve docs
23 | ```
24 |
25 | ## Deploying
26 |
27 | This site is deployed utilizing GitHub Pages. New commits trigger updates of websites.
28 |
29 | ## Url of resource files (Code in TensorFlow.NET Practice)
30 | Url: https://pan.baidu.com/s/1dbxfy-GByGkYxqYcdmcI8g?pwd=bvbk
31 |
32 | Extraction code: bvbk
33 |
--------------------------------------------------------------------------------
/docs/.nojekyll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/.nojekyll
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | 
4 |
5 |
14 |
15 | > - Bypassing python, TF.NET starts from C# to [C code](https://www.tensorflow.org/). Efficiency++!
16 | > - Cross-platform! Support .NET Standard!
17 | > - Independent package [Keras](<(https://www.nuget.org/packages/TensorFlow.Keras/)>) without downloading TF.NET!
18 |
--------------------------------------------------------------------------------
/docs/_images/Automatic-Differentiation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/Automatic-Differentiation.png
--------------------------------------------------------------------------------
/docs/_images/FIFOQueue-example.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/FIFOQueue-example.jpg
--------------------------------------------------------------------------------
/docs/_images/column-major-order.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/column-major-order.png
--------------------------------------------------------------------------------
/docs/_images/contiguous-block-of-memory-ndarray-example-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/contiguous-block-of-memory-ndarray-example-1.png
--------------------------------------------------------------------------------
/docs/_images/contiguous-block-of-memory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/contiguous-block-of-memory.png
--------------------------------------------------------------------------------
/docs/_images/front-cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/front-cover.jpg
--------------------------------------------------------------------------------
/docs/_images/gradient-descent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/gradient-descent.png
--------------------------------------------------------------------------------
/docs/_images/linear-regression-tensor-board.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/linear-regression-tensor-board.png
--------------------------------------------------------------------------------
/docs/_images/logistic-regression/1557035393445.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/logistic-regression/1557035393445.png
--------------------------------------------------------------------------------
/docs/_images/minimize-square-cost.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/minimize-square-cost.png
--------------------------------------------------------------------------------
/docs/_images/new-project-console.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/new-project-console.png
--------------------------------------------------------------------------------
/docs/_images/new-project.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/new-project.png
--------------------------------------------------------------------------------
/docs/_images/regression-dataset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/regression-dataset.png
--------------------------------------------------------------------------------
/docs/_images/row-major-order.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/row-major-order.png
--------------------------------------------------------------------------------
/docs/_images/sigmoid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/sigmoid.png
--------------------------------------------------------------------------------
/docs/_images/tensor-constant-ndarray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/tensor-constant-ndarray.png
--------------------------------------------------------------------------------
/docs/_images/tensor-naming.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/tensor-naming.png
--------------------------------------------------------------------------------
/docs/_images/tf.net.logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_images/tf.net.logo.png
--------------------------------------------------------------------------------
/docs/_media/Cover.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/Cover.psd
--------------------------------------------------------------------------------
/docs/_media/Logo.md:
--------------------------------------------------------------------------------
1 | TensorFlow.NET logo (c) 2019 by Meinrad Recheis.
2 |
3 | The logo is based on the original TensorFlow logo which is copyrighted by the respective creator.
--------------------------------------------------------------------------------
/docs/_media/TIM.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/TIM.jpg
--------------------------------------------------------------------------------
/docs/_media/TensorBoard-nn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/TensorBoard-nn.png
--------------------------------------------------------------------------------
/docs/_media/WeChatCollection.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/WeChatCollection.jpg
--------------------------------------------------------------------------------
/docs/_media/cnn-result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/cnn-result.png
--------------------------------------------------------------------------------
/docs/_media/cnn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/cnn.png
--------------------------------------------------------------------------------
/docs/_media/csharp-vs-python-speed.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/csharp-vs-python-speed.mp4
--------------------------------------------------------------------------------
/docs/_media/csharp_vs_python_speed_memory.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/csharp_vs_python_speed_memory.jpg
--------------------------------------------------------------------------------
/docs/_media/eager-mode-add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/eager-mode-add.png
--------------------------------------------------------------------------------
/docs/_media/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/favicon.ico
--------------------------------------------------------------------------------
/docs/_media/graph_vis_animation.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/graph_vis_animation.gif
--------------------------------------------------------------------------------
/docs/_media/mnist.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/mnist.png
--------------------------------------------------------------------------------
/docs/_media/nn-result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/nn-result.png
--------------------------------------------------------------------------------
/docs/_media/nn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/nn.png
--------------------------------------------------------------------------------
/docs/_media/performance-comparison.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/performance-comparison.jpg
--------------------------------------------------------------------------------
/docs/_media/syntax-comparision.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/syntax-comparision.png
--------------------------------------------------------------------------------
/docs/_media/tensors_flowing.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/tensors_flowing.gif
--------------------------------------------------------------------------------
/docs/_media/tf.net.icon-purple128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/tf.net.icon-purple128.png
--------------------------------------------------------------------------------
/docs/_media/tf.net.icon-purple512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/tf.net.icon-purple512.png
--------------------------------------------------------------------------------
/docs/_media/tf.net.icon-transparent128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/tf.net.icon-transparent128.png
--------------------------------------------------------------------------------
/docs/_media/tf.net.icon-transparent512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/tf.net.icon-transparent512.png
--------------------------------------------------------------------------------
/docs/_media/tf.net.logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/tf.net.logo.png
--------------------------------------------------------------------------------
/docs/_media/tf.net.logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/tf.net.logo512.png
--------------------------------------------------------------------------------
/docs/_media/tf2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/tf2.jpg
--------------------------------------------------------------------------------
/docs/_media/tf2.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/docs/_media/tf2.psd
--------------------------------------------------------------------------------
/docs/_navbar.md:
--------------------------------------------------------------------------------
1 | * [Eng](/)
2 | * [中文](/zh-cn/)
3 |
--------------------------------------------------------------------------------
/docs/_scripts/make-sidebar.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | pathToLookUpDirectory = "docs/components"
4 | # files = [f for f in os.listdir(pathToLookUpDirectory) if os.path.isfile(f)]
5 | files = [f for f in os.listdir(pathToLookUpDirectory)]
6 |
7 | sidebar_file = open('_sidebarPending.md', 'w')
8 | for file in files:
9 | if ".md" in file:
10 | name = file.split(".md")
11 | file = file.replace(" ", "%20")
12 | sidebar_file.write( f"* [{name[0]}]({file})\n" )
13 | sidebar_file.close()
14 |
--------------------------------------------------------------------------------
/docs/_sidebar.md:
--------------------------------------------------------------------------------
1 |
2 | * 💡 Essentials
3 | * [Installation](essentials/installation.md)
4 | * [Introduction](essentials/introduction.md)
5 | * [Tips](essentials/tips.md)
6 |
7 |
8 | * 🎓 Tutorials
9 | * [Hello World](tutorials/HelloWorld.md)
10 | * [Image Recognition](tutorials/ImageRecognition.md)
11 | * [Mnist In Rnn](tutorials/MnistInRnn.md)
12 | * [Examples](tutorials/examples.md)
13 |
14 |
15 | * 🧊 Components
16 |
17 |
18 |
19 |
20 | * [Tensor](components/tensor.md)
21 | * [Constant](components/Constant.md)
22 | * [Variable](components/Variable.md)
23 | * [Placeholder](components/Placeholder.md)
24 | * [Graph](components/Graph.md)
25 | * [Session](components/Session.md)
26 | * [Operation](components/Operation.md)
27 | * [Queue](components/Queue.md)
28 | * [Gradient](components/Gradient.md)
29 | * [Train](components/Train.md)
30 | * [Eager Mode](components/EagerMode.md)
31 | * [Linear Regression](components/LinearRegression.md)
32 | * [Logistic Regression](components/LogisticRegression.md)
33 | * [Nearest Neighbor](components/NearestNeighbor.md)
34 | * [Neural Network](components/NeuralNetwork.md)
35 | * [Convolution Neural Network](components/ConvolutionNeuralNetwork.md)
36 |
37 |
38 | * ✔️ API
39 | * [tf](api/tf.md)
40 | * [tf.nn](api/tf.nn.md)
41 |
42 |
43 | * ❤️ Contribute
44 | * [Contribute](contribute/contribute.md)
45 | * [Contact](contribute/contact.md)
46 |
47 |
--------------------------------------------------------------------------------
/docs/components/EagerMode.md:
--------------------------------------------------------------------------------
1 | # Eager Mode
2 |
3 | TensorFlow's eager execution is an imperative programming environment that evaluates operations immediately, without building graphs: operations return concrete values instead of constructing a computational graph to run later. This makes it easy to get started with TensorFlow and debug models, and it reduces boilerplate as well.
--------------------------------------------------------------------------------
/docs/components/Foreword.md:
--------------------------------------------------------------------------------
1 | # Foreword
2 |
3 | One of the most nerve-wracking periods when releasing the first version of an open source project occurs when the [gitter](https://gitter.im/sci-sharp/community) community is created. You are all alone, eagerly hoping and wishing for the first user to come along. I still vividly remember those days.
4 |
5 |
6 |
7 | TensorFlow.NET is my third open source project. BotSharp and NumSharp are the first two. The response is pretty good. I also got a lot of stars on github. Although the first two projects are very difficult, I can't admit that TensorFlow.NET is much more difficult than the previous two, and it is an area I have never been involved with. Mainly related to GPU parallel computing, distributed computing and neural network model. When I started writing this project, I was also sorting out the idea of the coding process. TensorFlow is a huge and complicated project, and it is easy to go beyond the scope of personal ability. Therefore, I want to record the thoughts at the time as much as possible. The process of recording and sorting clears the way of thinking.
8 |
9 |
10 |
11 | All the examples in this book can be found in the github repository of TensorFlow.NET. When the source code and the code in the book are inconsistent, please refer to the source code. The sample code is typically located in the Example or UnitTest project.
12 |
--------------------------------------------------------------------------------
/docs/components/FrontCover.md:
--------------------------------------------------------------------------------
1 | # The Definitive Guide to TensorFlow.NET
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | ### The CSharp binding for Google's TensorFlow
23 |
24 | #### An Open Source Machine Learning Framework for Everyone
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | Haiping Chen
38 | Christmas, 2018
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/docs/components/Gradient.md:
--------------------------------------------------------------------------------
1 | # Gradient
2 |
3 | ## Register custom gradient function
4 |
5 | TF.NET is extensible which can be added custom gradient function.
6 |
7 | ```csharp
8 | // define gradient function
9 | ops.RegisterGradientFunction("ConcatV2", (oper, out_grads) =>
10 | {
11 | var grad = grads[0];
12 | return new Tensor[]{ };
13 | });
14 | ```
15 |
16 |
--------------------------------------------------------------------------------
/docs/components/Graph.md:
--------------------------------------------------------------------------------
1 | # Graph
2 |
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(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 | 
23 |
24 |
25 |
26 | ## Save Model
27 |
28 | Saving the model means saving all the values of the parameters and the graph.
29 |
30 | ```python
31 | saver = tf.train.Saver()
32 | saver.save(sess,'./tensorflowModel.ckpt')
33 | ```
34 |
35 | After saving the model there will be four files:
36 |
37 | * tensorflowModel.ckpt.meta:
38 | * tensorflowModel.ckpt.data-00000-of-00001:
39 | * tensorflowModel.ckpt.index
40 | * checkpoint
41 |
42 | We also created a protocol buffer file .pbtxt. It is human readable if you want to convert it to binary: `as_text: false`.
43 |
44 | * tensorflowModel.pbtxt:
45 |
46 | This holds a network of nodes, each representing one operation, connected to each other as inputs and outputs.
47 |
48 |
49 |
50 | ## Freezing the Graph
51 |
52 | ### *Why we need it?*
53 |
54 | When we need to keep all the values of the variables and the Graph structure in a single file we have to freeze the graph.
55 |
56 | ```csharp
57 | from tensorflow.python.tools import freeze_graph
58 |
59 | freeze_graph.freeze_graph(input_graph = 'logistic_regression/tensorflowModel.pbtxt',
60 | input_saver = "",
61 | input_binary = False,
62 | input_checkpoint = 'logistic_regression/tensorflowModel.ckpt',
63 | output_node_names = "Softmax",
64 | restore_op_name = "save/restore_all",
65 | filename_tensor_name = "save/Const:0",
66 | output_graph = 'frozentensorflowModel.pb',
67 | clear_devices = True,
68 | initializer_nodes = "")
69 |
70 | ```
71 |
72 | ## Optimizing for Inference
73 |
74 | To Reduce the amount of computation needed when the network is used only for inferences we can remove some parts of a graph that are only needed for training.
75 |
76 |
77 |
78 | ## Restoring the Model
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/docs/components/LogisticRegression.md:
--------------------------------------------------------------------------------
1 | # Logistic Regression
2 |
3 | ## What is logistic regression?
4 |
5 | Logistic regression is a statistical analysis method used to predict a data value based on prior observations of a data set. A logistic regression model predicts a dependent data variable by analyzing the relationship between one or more existing independent variables.
6 |
7 |
8 |
9 | The dependent variable of logistics regression can be two-category or multi-category, but the two-category is more common and easier to explain. So the most common use in practice is the logistics of the two classifications. An example used by TensorFlow.NET is a hand-written digit recognition, which is a multi-category.
10 |
11 |
12 |
13 | Softmax regression allows us to handle  where K is the number of classes.
14 |
15 |
16 | The full example is [here](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/LogisticRegression.cs).
17 |
--------------------------------------------------------------------------------
/docs/components/NearestNeighbor.md:
--------------------------------------------------------------------------------
1 | # Nearest Neighbor
2 |
3 | The nearest neighbour algorithm was one of the first algorithms used to solve the travelling salesman problem. In it, the salesman starts at a random city and repeatedly visits the nearest city until all have been visited. It quickly yields a short tour, but usually not the optimal one.
4 |
5 | The full example is [here](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/NearestNeighbor.cs).
--------------------------------------------------------------------------------
/docs/components/Operation.md:
--------------------------------------------------------------------------------
1 | # Operation
2 |
3 | `Operation` represents a `Graph` node that performs computation on tensors. An operation is a `Node` in a `Graph` that takes zero or more `Tensor`s (produced by other Operations in the Graph) as input, and produces zero or more Tensors as output.
--------------------------------------------------------------------------------
/docs/components/Placeholder.md:
--------------------------------------------------------------------------------
1 | # Placeholder
2 |
3 | In this chapter we will talk about another common data type in TensorFlow: Placeholder. It is a simplified variable that can be passed to the required value by the session when the graph is run, that is, when you build the graph, you don't need to specify the value of that variable, but delay the session to the beginning. In TensorFlow terminology, we then feed data into the graph through these placeholders. The difference between placeholders and constants is that placeholders can specify coefficient values more flexibly without modifying the code that builds the graph. For example, mathematical constants are suitable for Constant, and some model smoothing values can be specified with Placeholder.
4 |
5 |
6 |
7 | ```csharp
8 | var x = tf.placeholder(tf.int32);
9 | var y = x * 3;
10 |
11 | using (var sess = tf.Session())
12 | {
13 | var result = sess.run(y, feed_dict: new FeedItem[]
14 | {
15 | new FeedItem(x, 2)
16 | });
17 | // (int)result should be 6;
18 | }
19 | ```
20 |
21 |
--------------------------------------------------------------------------------
/docs/components/Preface.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Preface
4 |
5 | Why do I start the TensorFlow.NET project?
6 |
7 | In a few days, it was Christmas in 2018. I watched my children grow up and be sensible every day, and I felt that time passed too fast. IT technology updates are faster than ever, and a variety of front-end technologies are emerging. Big data, Artificial Intelligence and Blockchain, Container technology and Microservices, Distributed Computing and Serverless technology are dazzling. The Amazon AI service interface claims that engineers who don't need any machine learning experience can use it, so that the idea of just calming down for two years and planning to switch to an AI architecture in the future is a splash of cold water.
8 |
9 |
10 |
11 | TensorFlow is an open source project for machine learning especially for deep learning. It's used for both research and production at Google company. It's designed according to dataflow programming pattern across a range of tasks. TensorFlow is not just a deep learning library. As long as you can represent your calculation process as a data flow diagram, you can use TensorFlow for distributed computing. TensorFlow uses a computational graph to build a computing network while operating on the graph. Users can write their own upper-level models in Python based on TensorFlow, or extend the underlying C++ custom action code to TensorFlow.
12 |
13 |
14 |
15 | In order to avoid confusion, the unique classes defined in TensorFlow are not translated in this book. For example, Tensor, Graph, Shape will retain the English name.
16 |
--------------------------------------------------------------------------------
/docs/components/Session.md:
--------------------------------------------------------------------------------
1 | # Session
2 |
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 |
6 |
7 | ## Running Computations in a Session
8 |
9 | Let's complete the example in last chapter. To run any of the operations, we need to create a session for that graph. The session will also allocate memory to store the current value of the variable.
10 |
11 |
12 |
13 | ```csharp
14 | with(tf.Graph(), graph =>
15 | {
16 | var variable = tf.Variable(31, name: "tree");
17 | var init = tf.global_variables_initializer();
18 |
19 | var sess = tf.Session(graph);
20 | sess.run(init);
21 |
22 | var result = sess.run(variable); // 31
23 |
24 | var assign = variable.assign(12);
25 | result = sess.run(assign); // 12
26 | });
27 | ```
28 |
29 | The value of our variables is only valid within one session. If we try to get the value in another session. TensorFlow will raise an error of `Attempting to use uninitialized value foo`. Of course, we can use the graph in more than one session, because session copies graph definition to new memory area. We just have to initialize the variables again. The values in the new session will be completely independent from the previous one.
30 |
--------------------------------------------------------------------------------
/docs/components/Table of Contents.md:
--------------------------------------------------------------------------------
1 | # Table of Contents
2 |
3 | ### Foreword...........................................................................................xxi
4 |
5 | ### Preface..............................................................................................xxiii
6 |
7 | ## Part I. Getting Started
8 |
9 | ##### 1. You Know, for Machine Learning............................................................................................ 3
10 |
11 | Installing TensorFlow.NET
12 | Running TensorFlow.NET
13 | Talking to TensorFlow.NET
14 |
15 | ##### 2. Hello World
16 |
17 |
18 |
19 | ## Part II. TensorFlow.NET in Depth
20 |
21 | ##### 1. Control Dependency ......................................................................................................
22 |
23 | ##### 2. Graph ....................................
24 |
25 | ##### 3. Session ............................
26 |
27 |
28 |
29 | ## Part III. Dealing with Human Language
30 |
31 | ##### 1. Text Classification ............................................................................................
32 |
33 | ##### 2. Named Entity Recognition ..............................................................................
34 |
35 | ##### 3. Sentiment Analyze ...........................................................................................
36 |
37 | ##### 4. Sentence Dependency ........................................................................
38 |
39 |
40 |
41 | ## Part IV. Image Recognition
42 |
43 | ##### 1. Inception Model ................................................................................................................. 100
44 |
45 |
--------------------------------------------------------------------------------
/docs/components/Train.md:
--------------------------------------------------------------------------------
1 | # Trainer
2 |
3 | ## Saver
4 |
5 | The `tf.train.saver` class provides methods to save and restore models.
6 |
7 |
8 |
9 | ## Saver Builder
10 |
11 | ### Bulk Saver Builder
12 |
13 |
--------------------------------------------------------------------------------
/docs/components/Variable.md:
--------------------------------------------------------------------------------
1 | # Variable
2 |
3 | The variables in TensorFlow are mainly used to represent variable parameter values in the machine learning model. Variables can be initialized by the `tf.Variable` function. During the graph computation the variables are modified by other operations. Variables exist in the session, as long as they are in the same session, other computing nodes on the network can access the same variable value. Variables use lazy loading and will only request memory space when they are used.
4 |
5 |
6 |
7 | ```csharp
8 | var x = tf.Variable(10, name: "x");
9 | using (var session = tf.Session())
10 | {
11 | session.run(x.initializer);
12 | var result = session.run(x);
13 | Console.Write(result); // should be 10
14 | }
15 | ```
16 |
17 | The above code first creates a variable operation, initializes the variable, then runs the session, and finally gets the result. This code is very simple, but it shows the complete process how TensorFlow operates on variables. When creating a variable, you pass a `tensor` as the initial value to the function `Variable()`. TensorFlow provides a series of operators to initialize the tensor, the initial value is a constant or a random value.
18 |
19 |
--------------------------------------------------------------------------------
/docs/components/tensor.md:
--------------------------------------------------------------------------------
1 | # Tensor
2 |
3 | > Represents one of the outputs of an Operation
4 |
5 |
6 |
7 | ## What is Tensor?
8 |
9 | Tensor holds a multi-dimensional array of elements of a single data type which is very similar with `NumPy`'s `ndarray`. When the dimension is zero, it can be called a scalar. When the dimension is 2, it can be called a matrix. When the dimension is greater than 2, it is usually called a tensor. If you are very familiar with `NumPy`, then understanding Tensor will be quite easy.
10 |
11 | 
12 |
13 | ## How to create a Tensor?
14 |
15 | There are many ways to initialize a Tensor object in TF.NET. It can be initialized from a scalar, string, matrix or tensor. But the best way to create a Tensor is using high level APIs like `tf.constant`, `tf.zeros` and `tf.ones`. We'll talk about constant more detail in next chapter.
16 |
17 | ```csharp
18 | // Create a tensor holds a scalar value
19 | var t1 = new Tensor(3);
20 |
21 | // Init from a string
22 | var t2 = new Tensor("Hello! TensorFlow.NET");
23 |
24 | // Tensor holds a ndarray
25 | var nd = new NDArray(new int[]{3, 1, 1, 2});
26 | var t3 = new Tensor(nd);
27 |
28 | Console.WriteLine($"t1: {t1}, t2: {t2}, t3: {t3}");
29 | ```
30 |
31 |
32 |
33 | ## Data Structure of Tensor
34 |
35 | TF uses column major order. If we generate a 2 x 3 matrix (`NDArray`), if we access the data from 0 to 5 in order, we won't get a number of 1-6, but we get the order of 1, 4, 2, 5, 3, 6. a set of numbers.
36 |
37 | ```csharp
38 | // Generate a matrix:[[1, 2, 3], [4, 5, 6]]
39 | var nd = np.array(1f, 2f, 3f, 4f, 5f, 6f).reshape(2, 3);
40 | // The index will be 0 2 4 1 3 5, it's column-major order.
41 | ```
42 |
43 |
44 | 
45 |
46 | 
47 |
48 | ## Index/ Slice of Tensor
49 |
50 | Tensor element can be accessed by `index` and `slice` related operations. Through some high level APIs, we can easily access specific dimension's data.
51 |
52 |
--------------------------------------------------------------------------------
/docs/contribute/contact.md:
--------------------------------------------------------------------------------
1 | # Contact
2 |
3 | Follow TF.NET on [Twitter](https://twitter.com/ScisharpStack), [Facebook](https://www.facebook.com/scisharp.stack.9), [Medium](https://medium.com/scisharp), [LinkedIn](https://www.linkedin.com/company/scisharp-stack/).
4 |
5 | Join the chat on [Gitter](https://gitter.im/sci-sharp/community).
6 |
7 | Scan QR code to join Tencent TIM group:
8 |
9 | 
10 |
11 | WeChat Sponsor 微信打赏:
12 |
13 | 
14 |
15 | TensorFlow.NET is a part of [SciSharp STACK](https://scisharp.github.io/SciSharp/)
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/contribute/contribute.md:
--------------------------------------------------------------------------------
1 | # Contribute
2 |
3 | Feel like contributing to one of the hottest projects in the Machine Learning field? Want to know how TensorFlow magically creates the computational graph? We appreciate every contribution however small. There are tasks for novices to experts alike, if everyone tackles only a small task the sum of contributions will be huge.
4 |
5 | You can:
6 | * Let everyone know about this project
7 | * Port TensorFlow unit tests from Python to C# or F#
8 | * Port missing TensorFlow code from Python to C# or F#
9 | * Port TensorFlow examples to C# or F# and raise issues if you come accross missing parts of the API
10 | * Debug one of the unit tests that is marked as Ignored to get it to work
11 | * Debug one of the not yet working examples and get it to work
12 |
13 | ### How to debug unit tests
14 |
15 | The best way to find out why a unit test is failing is to single step it in C# or F# and its corresponding Python at the same time to see where the flow of execution digresses or where variables exhibit different values. Good Python IDEs like PyCharm let you single step into the tensorflow library code.
16 |
17 | ### Git Knowhow for Contributors
18 |
19 | Add SciSharp/TensorFlow.NET as upstream to your local repo ...
20 | ```bash
21 | git remote add upstream git@github.com:SciSharp/TensorFlow.NET.git
22 | ```
23 |
24 | Please make sure you keep your fork up to date by regularly pulling from upstream.
25 | ```bash
26 | git pull upstream master
27 | ```
28 |
29 | #### Update forked repo
30 |
31 | ```bash
32 | # ensures current branch is master
33 | git checkout master
34 |
35 | # pulls all new commits made to upstream/master
36 | git pull upstream master
37 |
38 | # this will delete all your local changes to master
39 | git reset --hard upstream/master
40 |
41 | # take care, this will delete all your changes on your forked master
42 | git push origin master --force
43 | ```
44 |
--------------------------------------------------------------------------------
/docs/essentials/installation.md:
--------------------------------------------------------------------------------
1 | # Installation
2 |
3 | ## Visual Studio
4 |
5 | Install TF.NET:
6 |
7 | ```bash
8 | ### install tensorflow C#/F# binding
9 | PM> Install-Package TensorFlow.NET
10 | ### install keras for tensorflow
11 | PM> Install-Package TensorFlow.Keras
12 | ```
13 |
14 | Install TensorFlow binary (**essential**). Choose one of the following:
15 |
16 | ```bash
17 | ### Install tensorflow binary
18 | ### For CPU version
19 | PM> Install-Package SciSharp.TensorFlow.Redist
20 |
21 | ### For GPU version (CUDA and cuDNN are required)
22 | PM> Install-Package SciSharp.TensorFlow.Redist-Windows-GPU
23 | ```
24 |
25 | ## dotnet CLI
26 |
27 | Install TF.NET:
28 |
29 | ```bash
30 | ### install tensorflow C#/F# binding
31 | dotnet add package TensorFlow.NET
32 | ### install keras for tensorflow
33 | dotnet add package TensorFlow.Keras
34 | ```
35 |
36 | Install TensorFlow binary (**essential**). Choose one of the following:
37 |
38 | ```bash
39 | ### Install tensorflow binary
40 | ### For CPU version
41 | dotnet add package SciSharp.TensorFlow.Redist
42 |
43 | ### For GPU version (CUDA and cuDNN are required)
44 | dotnet add package SciSharp.TensorFlow.Redist-Windows-GPU
45 |
46 | ```
47 |
48 | > ...noted that the version digits of the binary (SciSharp.TensorFlow.Redist\*) is the same as that of Google's TensorFlow.
49 | >
50 | > ...if GPU package is chosen, **make very sure** that if the versions of TensorFlow (i.e. `tf native`) and CUDA are compatible:
51 | >
52 | > | TF.NET \ TensorFlow | tf native 1.14, cuda 10.0 | tf native 1.15, cuda 10.0 | tf native 2.3, cuda 10.1 | tf native 2.4, cuda 11 |
53 | > | ------------------------- | :-----------------------: | :-----------------------: | :----------------------: | :--------------------: |
54 | > | tf.net 0.4x, tf.keras 0.5 | | | | x |
55 | > | tf.net 0.3x, tf.keras 0.2 | | | x | |
56 | > | tf.net 0.2x | | x | x | |
57 | > | tf.net 0.15 | x | x | | |
58 | > | tf.net 0.14 | x | | | |
59 |
60 | ## Troubleshooting
61 |
62 | Still got some problems?
63 |
64 | - [More detailed local documentation](essentials/installationTroubleshooting.md).
65 | - [Microsoft official documentation](https://docs.microsoft.com/en-us/dotnet/api/microsoft.ml.vision.imageclassificationtrainer?view=ml-dotnet#using-tensorflow-based-apis).
66 | - [Step-by-step setup tutorial](https://medium.com/dev-genius/tensorflow-basic-setup-for-net-developers-d56bfb0af40e).
67 | - Or [post](https://github.com/SciSharp/TensorFlow.NET/issues) an issue for help!
68 |
--------------------------------------------------------------------------------
/docs/essentials/installationTroubleshooting.md:
--------------------------------------------------------------------------------
1 | # Installation Troubleshooting
2 |
3 | TensorFlow.NET pack all required libraries in architecture-specific assemblies folders per NuGet standard.
4 |
5 | ```bash
6 | PM> Install-Package TensorFlow.NET
7 | PM> Install-Package SciSharp.TensorFlow.Redist
8 | ```
9 |
10 | Add `win-x64` to a `PropertyGroup` in your `.csproj` when targeting `.NET 472`.
11 |
12 | ### Run in Linux
13 |
14 | Download Linux pre-built library and unzip `libtensorflow.so` and `libtensorflow_framework.so` into current running directory.
15 |
16 | To run image recognition in Linux, please ensure some prerequisite libraries is install.
17 |
18 | ```shell
19 | sudo apt install libc6-dev
20 | sudo apt install libgdiplus
21 | ```
22 |
23 | More information about [System.Drawing on Linux]().
24 |
25 | ### Run TensorFlow with GPU
26 |
27 | Before running verify you installed CUDA and cuDNN (TensorFlow v1.15 is compatible with CUDA v10.0 and cuDNN v7.4 , TensorFlow v2.x is compatible with CUDA v10.2 and cuDNN v7.65), and make sure the corresponding cuda version is compatible.
28 |
29 | #### Mac OS
30 |
31 | There is no GPU support for macOS.
32 |
33 | #### GPU for Windows
34 |
35 | ```bash
36 | PM> Install-Package SciSharp.TensorFlow.Redist-Windows-GPU
37 | ```
38 |
39 | #### GPU for Linux
40 |
41 | ```bash
42 | PM> Install-Package SciSharp.TensorFlow.Redist-Linux-GPU
43 | ```
44 |
45 | ### Download prebuild binary manually
46 |
47 | TensorFlow packages are built nightly and uploaded to GCS for all supported platforms. They are uploaded to the [libtensorflow-nightly](https://www.tensorflow.org/install/lang_c) GCS bucket and are indexed by operating system and date built.
48 |
49 |
50 | ### Build from source for Windows
51 |
52 | https://www.tensorflow.org/install/source_windows
53 |
54 | Download [Bazel 2.0.0](https://github.com/bazelbuild/bazel/releases/tag/2.0.0) to build tensorflow2.x. We build customized binary to export c_api from this [fork](https://github.com/SciSharp/tensorflow).
55 |
56 | Set ENV `BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC`.
57 |
58 | `pacman -S git patch unzip`
59 |
60 | 1. Build static library
61 |
62 | `bazel build --config=opt //tensorflow:tensorflow`
63 |
64 | 2. Build pip package
65 |
66 | `bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package`
67 |
68 | 3. Generate pip installation file
69 |
70 | `bazel-bin\tensorflow\tools\pip_package\build_pip_package C:/tmp/tensorflow_pkg`
71 |
72 | 4. Install from local wheel file.
73 |
74 | `pip install C:/tmp/tensorflow_pkg/tensorflow-1.15.0-cp36-cp36m-win_amd64.whl`
75 |
76 | ### Build specific version for tf.net
77 |
78 | https://github.com/SciSharp/tensorflow
79 |
80 | For Linux version, these APIs symbols should also be put into `tensorflow/c/version_script.lds` to be exported.
81 | Please refer to commit `https://github.com/SciSharp/tensorflow/commit/58122da06be3e7707500ad889dfd5c760a3e0424`
82 |
--------------------------------------------------------------------------------
/docs/essentials/tips.md:
--------------------------------------------------------------------------------
1 | # Tips
2 |
3 | ## Use functions from `tf` if possible
4 |
5 | Math operations on `np` is **not stable** for now. Try those alternatives in `tf` if possible.
6 |
7 | For example, use this:
8 |
9 | ```csharp
10 | tf.matmul();
11 | ```
12 |
13 | ...rather than this:
14 |
15 | ```csharp
16 | np.matmul();
17 | ```
18 |
19 | ## Use `np` if saving/loading `Tensor`
20 |
21 | ## Use the latest TF.NET version
22 |
23 | Since TF.NET version correlates that of native TensorFlow, which in turn links to the version of CUDA, it is inconvenient. Though, it is a mission impossible for the small team to maintain all the TF.NET versions. Please use the latest package if possible.
24 |
--------------------------------------------------------------------------------
/docs/tutorials/HelloWorld.md:
--------------------------------------------------------------------------------
1 | # Get started with TensorFlow.NET
2 |
3 | I would describe TensorFlow as an open source machine learning framework developed by Google which can be used to build neural networks and perform a variety of machine learning tasks. it works on data flow graph where nodes are the mathematical operations and the edges are the data in the form of tensor, hence the name Tensor-Flow.
4 |
5 |
6 |
7 | 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.
8 |
9 |
10 |
11 | ## Install the TensorFlow.NET SDK
12 |
13 | TensorFlow.NET uses the .NET Standard 2.0 standard, so your new project Target Framework can be .NET Framework or .NET Core/ .NET 5. All the examples in this book are using .NET Core 3.1 and Microsoft Visual Studio Community 2019. 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.
14 |
15 |
16 |
17 | 1. New a project
18 |
19 | 
20 |
21 | 2. Choose Console App (.NET Core)
22 |
23 | 
24 |
25 |
26 |
27 | ```bash
28 | ### install tensorflow C# binding
29 | PM> Install-Package TensorFlow.NET
30 |
31 | ### Install tensorflow binary
32 | ### For CPU version
33 | PM> Install-Package SciSharp.TensorFlow.Redist
34 |
35 | ### For GPU version (CUDA and cuDNN are required)
36 | PM> Install-Package SciSharp.TensorFlow.Redist-Windows-GPU
37 | ```
38 |
39 | ## Start coding Hello World
40 |
41 | After installing the TensorFlow.NET package, you can use the `using static Tensorflow.Binding` to introduce the TensorFlow .NET library.
42 |
43 | TensorFlow 2.x enabled `Eager Mode` by default. About what eager mode is, I will introduce it in detail in the following chapters.
44 |
45 | ```csharp
46 | using System;
47 | using static Tensorflow.Binding;
48 |
49 | namespace TensorFlowNET.Examples
50 | {
51 | ///
52 | /// Simple hello world using TensorFlow
53 | ///
54 | class Program
55 | {
56 | static void Main(string[] args)
57 | {
58 | var hello = tf.constant("Hello, TensorFlow!");
59 | Console.WriteLine(hello);
60 | }
61 | }
62 | }
63 | ```
64 | After CTRL + F5 run, you will get the output.
65 | ```bash
66 | 9/20/2020 2:15:09 AM Starting Hello World
67 | tf.Tensor: shape=(), dtype=string, numpy=Hello, TensorFlow.NET!
68 | 9/20/2020 2:15:09 AM Completed Hello World
69 | Example: Hello World in 0.1273463s is OK!
70 | TensorFlow.NET v0.20.1.0
71 | TensorFlow Binary v2.3.0
72 | 1 of 21 example(s) are completed.
73 | Press [Enter] to continue...
74 | ```
75 |
76 | This sample code can be found at [here](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/HelloWorld.cs).
77 |
78 |
--------------------------------------------------------------------------------
/docs/tutorials/MnistInRnn.md:
--------------------------------------------------------------------------------
1 | # MNIST In RNN
2 |
3 | ## Recurrent Neural Networks
4 |
5 | Recurrent Neural Networks (RNNs) are popular models that have shown great promise in sequential data classification task. The traditional neural network model cannot make the next prediction input based on the knowledge that has been learned before.
--------------------------------------------------------------------------------
/docs/tutorials/examples.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 | [TensorFlowNET.Examples](https://github.com/SciSharp/SciSharp-Stack-Examples/tree/master/src/TensorFlowNET.Examples)
4 |
5 | - [Audio Processing](https://github.com/SciSharp/SciSharp-Stack-Examples/tree/master/src/TensorFlowNET.Examples/AudioProcessing)
6 |
7 | - [Basic Models](https://github.com/SciSharp/SciSharp-Stack-Examples/tree/master/src/TensorFlowNET.Examples/BasicModels)
8 | - [K Means Clustering](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/KMeansClustering.cs)
9 | - [Linear Regression](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/LinearRegression.cs)
10 | - [Linear Regression Eager](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/LinearRegressionEager.cs)
11 | - [Logistic Regression](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/LogisticRegression.cs)
12 | - [Logistic Regression Eager](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/LogisticRegressionEager.cs)
13 | - [Naive Bayes Classifier](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs)
14 | - [Nearest Neighbor](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/NearestNeighbor.cs)
15 |
16 | - [Converting](https://github.com/SciSharp/SciSharp-Stack-Examples/tree/master/src/TensorFlowNET.Examples/Converting)
17 |
18 | - [Image Processing](https://github.com/SciSharp/SciSharp-Stack-Examples/tree/master/src/TensorFlowNET.Examples/ImageProcessing)
19 |
20 | - [Basic Operations](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicOperations.cs)
21 |
22 | - [AutoGraph](https://medium.com/scisharp/tensorflow-autograph-for-net-a89f1e97a4a5)
23 |
24 | - Automatic Differentiation
25 |
26 | 
27 |
--------------------------------------------------------------------------------
/docs/zh-cn/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | 
4 |
5 |
13 |
14 | > - 无视 python 层,从 C# 直通 [C 代码](https://www.tensorflow.org/),效率++!
15 | > - 跨平台!支持 .NET Standard!
16 | > - 可无需下载整个 TF.NET,直接使用 [Keras](<(https://www.nuget.org/packages/TensorFlow.Keras/)>)!
17 |
--------------------------------------------------------------------------------
/docs/zh-cn/_sidebar.md:
--------------------------------------------------------------------------------
1 | * 💡 必看
2 | * [安装依赖包](zh-cn/essentials/installation.md)
3 | * [介绍](zh-cn/essentials/introduction.md)
4 | * [注意事项](zh-cn/essentials/tips.md)
5 |
6 |
7 | * 🎓 教程
8 | * [例子](zh-cn/tutorials/examples.md)
9 |
10 |
11 | * ✔️ API
12 | * [tf](api/tf.md)
13 | * [tf.nn](api/tf.nn.md)
14 |
15 |
16 | * ❤️ 加入专业团队
17 | * [帮忙写点代码](zh-cn/contribute/contribute.md)
18 | * [联系一下专业团队](zh-cn/contribute/contact.md)
19 |
--------------------------------------------------------------------------------
/docs/zh-cn/contribute/contact.md:
--------------------------------------------------------------------------------
1 | # 交流
2 |
3 | 来这里看点一手消息 [Twitter](https://twitter.com/ScisharpStack), [Facebook](https://www.facebook.com/scisharp.stack.9), [Medium](https://medium.com/scisharp), [LinkedIn](https://www.linkedin.com/company/scisharp-stack/).
4 |
5 | 这里参与讨论 [Gitter](https://gitter.im/sci-sharp/community).
6 |
7 | 或者到 QQ 群里整活:
8 |
9 | 
10 |
11 | 微信打赏谢谢了老铁们:
12 |
13 | 
14 |
15 | TensorFlow.NET 隶属于 [SciSharp STACK](https://scisharp.github.io/SciSharp/)
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/zh-cn/contribute/contribute.md:
--------------------------------------------------------------------------------
1 | # 帮忙写点代码
2 |
3 | 这个项目其实是一个天坑,目前还是有点缺人滴……
4 |
5 | 一起来:
6 |
7 | * 宣传一波
8 | * 整点用 C# 或者 F# 写的 TensorFlow 测试用例
9 | * 帮忙填填没写完的坑
10 | * 到[项目里](https://github.com/SciSharp/TensorFlow.NET/issues)写点 issues
11 |
12 | ### 如何搞定 Git
13 |
14 | 在你的 fork 仓库里面将 SciSharp/TensorFlow.NET 作为你的上游 upstream:
15 |
16 | ```bash
17 | git remote add upstream git@github.com:SciSharp/TensorFlow.NET.git
18 | ```
19 |
20 | 更新一下你的 fork 仓库:
21 |
22 | ```bash
23 | git pull upstream master
24 | ```
25 |
26 | #### 更新 forked 仓库
27 |
28 | ```bash
29 | # 确保当前的分支(branch)是 master
30 | git checkout master
31 |
32 | # 将【主仓库】(upstream/master)的所有改变都下载到【本地仓库】
33 | # 此时并不会覆盖你本地仓库的内容
34 | git pull upstream master
35 |
36 | # 注意!这会【删除】你【本地仓库】的所有改变,相当于重新对【主仓库】(upstream)做一次 fork
37 | git reset --hard upstream/master
38 |
39 | # 注意!这会将你【 GitHub 上的仓库】强行同步为你【当前的本地仓库】
40 | git push origin master --force
41 | ```
42 |
--------------------------------------------------------------------------------
/docs/zh-cn/essentials/installation.md:
--------------------------------------------------------------------------------
1 | # 安装
2 |
3 | ## Visual Studio
4 |
5 | 安装 TF.NET:
6 |
7 | ```bash
8 | ### install tensorflow C#/F# binding
9 | PM> Install-Package TensorFlow.NET
10 | ### install keras for tensorflow
11 | PM> Install-Package TensorFlow.Keras
12 | ```
13 |
14 | 安装 TensorFlow binary (**必要**). 在下面选择其一运行:
15 |
16 | ```bash
17 | ### Install tensorflow binary
18 | ### For CPU version
19 | PM> Install-Package SciSharp.TensorFlow.Redist
20 |
21 | ### For GPU version (CUDA and cuDNN are required)
22 | PM> Install-Package SciSharp.TensorFlow.Redist-Windows-GPU
23 | ```
24 |
25 | ## dotnet CLI
26 |
27 | 安装 TF.NET:
28 |
29 | ```bash
30 | ### install tensorflow C#/F# binding
31 | dotnet add package TensorFlow.NET
32 | ### install keras for tensorflow
33 | dotnet add package TensorFlow.Keras
34 | ```
35 |
36 | 安装 TensorFlow binary (**必要**). 在下面选择其一运行:
37 |
38 | ```bash
39 | ### Install tensorflow binary
40 | ### For CPU version
41 | dotnet add package SciSharp.TensorFlow.Redist
42 |
43 | ### For GPU version (CUDA and cuDNN are required)
44 | dotnet add package SciSharp.TensorFlow.Redist-Windows-GPU
45 | ```
46 |
47 | > ……binary (SciSharp.TensorFlow.Redist\*) 的版本号跟 Google 的 TensorFlow 是一致的。
48 | >
49 | > ……如果选了 GPU 依赖, **必须**确认 TensorFlow (i.e. `tf native`) 和 CUDA 的版本是能够兼容的:
50 | >
51 | > | TF.NET \ TensorFlow | tf native 1.14, cuda 10.0 | tf native 1.15, cuda 10.0 | tf native 2.3, cuda 10.1 | tf native 2.4, cuda 11 |
52 | > | ------------------------- | :-----------------------: | :-----------------------: | :----------------------: | :--------------------: |
53 | > | tf.net 0.4x, tf.keras 0.5 | | | | x |
54 | > | tf.net 0.3x, tf.keras 0.2 | | | x | |
55 | > | tf.net 0.2x | | x | x | |
56 | > | tf.net 0.15 | x | x | | |
57 | > | tf.net 0.14 | x | | | |
58 |
59 | ## 疑难杂症
60 |
61 | 仍被问题所困扰?
62 |
63 | - 到 [更深入的技术文档](essentials/installationTroubleshooting.md) 看看有没有解决方法。
64 | - [微软官方文档](https://docs.microsoft.com/zh-cn/dotnet/api/microsoft.ml.vision.imageclassificationtrainer?view=ml-dotnet#using-tensorflow-based-apis).
65 | - [手把手安装教程(英文)](https://medium.com/dev-genius/tensorflow-basic-setup-for-net-developers-d56bfb0af40e).
66 | - 或者干脆 [发个 issue](https://github.com/SciSharp/TensorFlow.NET/issues) 找人帮忙看看。
67 |
--------------------------------------------------------------------------------
/docs/zh-cn/essentials/tips.md:
--------------------------------------------------------------------------------
1 | # 注意事项
2 |
3 | ## 能用 `tf` 就尽量用
4 |
5 | `np` 的数学运算暂时**不稳定**. 如果 `tf` 做了相关的算术功能,就改用 `tf`.
6 |
7 | 举个栗子,尽量用这个:
8 |
9 | ```csharp
10 | tf.matmul();
11 | ```
12 |
13 | ……也别用这个:
14 |
15 | ```csharp
16 | np.matmul();
17 | ```
18 |
19 | ## 保存/载入 `Tensor` 还是推荐用 `np`
20 |
21 | ## 尽量用最新版本的 TF.NET
22 |
23 | TF.NET 的版本是跟 TensorFlow 的紧密相连的,并且会连带决定该用哪个版本的 CUDA。但是我们作为小团队很难同时维护所有的 TF.NET 版本,因此最好用最新版本。
24 |
--------------------------------------------------------------------------------
/docs/zh-cn/tutorials/examples.md:
--------------------------------------------------------------------------------
1 | # 例子
2 |
3 | [TensorFlowNET.Examples](https://github.com/SciSharp/SciSharp-Stack-Examples/tree/master/src/TensorFlowNET.Examples)
4 |
5 | - [音频处理](https://github.com/SciSharp/SciSharp-Stack-Examples/tree/master/src/TensorFlowNET.Examples/AudioProcessing)
6 |
7 | - [基础模型](https://github.com/SciSharp/SciSharp-Stack-Examples/tree/master/src/TensorFlowNET.Examples/BasicModels)
8 | - [K-Means 算法](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/KMeansClustering.cs)
9 | - [线性回归](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/LinearRegression.cs)
10 | - [线性回归 Eager](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/LinearRegressionEager.cs)
11 | - [逻辑回归](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/LogisticRegression.cs)
12 | - [逻辑回归 Eager](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/LogisticRegressionEager.cs)
13 | - [朴素贝叶斯分类器](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs)
14 | - [最邻近搜索](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicModels/NearestNeighbor.cs)
15 |
16 | - [转化](https://github.com/SciSharp/SciSharp-Stack-Examples/tree/master/src/TensorFlowNET.Examples/Converting)
17 |
18 | - [图像处理](https://github.com/SciSharp/SciSharp-Stack-Examples/tree/master/src/TensorFlowNET.Examples/ImageProcessing)
19 |
20 | - [基本操作](https://github.com/SciSharp/SciSharp-Stack-Examples/blob/master/src/TensorFlowNET.Examples/BasicOperations.cs)
21 |
22 | - [AutoGraph](https://medium.com/scisharp/tensorflow-autograph-for-net-a89f1e97a4a5)
23 |
24 | - 自动求导
25 |
26 | 
27 |
--------------------------------------------------------------------------------