├── .gitignore ├── Code in TensorFlow.NET Practice ├── CnnTextClassification │ ├── CnnTextClassification.sln │ └── CnnTextClassification │ │ ├── CnnTextClassification.csproj │ │ ├── Program.cs │ │ └── obj │ │ ├── CnnTextClassification.csproj.nuget.dgspec.json │ │ ├── CnnTextClassification.csproj.nuget.g.props │ │ ├── CnnTextClassification.csproj.nuget.g.targets │ │ ├── Debug │ │ └── net5.0 │ │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ │ ├── CnnTextClassification.AssemblyInfo.cs │ │ │ ├── CnnTextClassification.AssemblyInfoInputs.cache │ │ │ ├── CnnTextClassification.GeneratedMSBuildEditorConfig.editorconfig │ │ │ ├── CnnTextClassification.assets.cache │ │ │ └── CnnTextClassification.csproj.AssemblyReference.cache │ │ ├── project.assets.json │ │ └── project.nuget.cache ├── DCGAN │ ├── DCGAN.sln │ └── DCGAN │ │ ├── DCGAN.csproj │ │ ├── Program.cs │ │ ├── bin │ │ └── Debug │ │ │ └── output.txt │ │ └── obj │ │ ├── DCGAN.csproj.nuget.dgspec.json │ │ ├── DCGAN.csproj.nuget.g.props │ │ ├── DCGAN.csproj.nuget.g.targets │ │ ├── project.assets.json │ │ └── project.nuget.cache ├── DNN_Eager │ ├── DNN_Eager.sln │ └── DNN_Eager │ │ ├── DNN_Eager.csproj │ │ └── Program.cs ├── DNN_Keras │ ├── DNN_Keras.sln │ └── DNN_Keras │ │ ├── DNN_Keras.csproj │ │ ├── Program.cs │ │ └── obj │ │ ├── DNN_Keras.csproj.nuget.dgspec.json │ │ ├── DNN_Keras.csproj.nuget.g.props │ │ ├── DNN_Keras.csproj.nuget.g.targets │ │ ├── project.assets.json │ │ └── project.nuget.cache ├── DNN_Keras_Functional │ ├── DNN_Keras_Functional.sln │ └── DNN_Keras_Functional │ │ ├── DNN_Keras_Functional.csproj │ │ ├── Program.cs │ │ └── obj │ │ ├── DNN_Keras_Functional.csproj.nuget.dgspec.json │ │ ├── DNN_Keras_Functional.csproj.nuget.g.props │ │ ├── DNN_Keras_Functional.csproj.nuget.g.targets │ │ ├── project.assets.json │ │ └── project.nuget.cache ├── ExploreCNN │ ├── ExploreCNN.sln │ ├── ExploreCNN │ │ ├── ExploreCNN.csproj │ │ ├── ExploreCNN.csproj.user │ │ ├── Form1.Designer.cs │ │ ├── Form1.cs │ │ ├── Form1.resx │ │ ├── ImageBox.cs │ │ ├── Program.cs │ │ └── obj │ │ │ ├── ExploreCNN.csproj.nuget.dgspec.json │ │ │ ├── ExploreCNN.csproj.nuget.g.props │ │ │ ├── ExploreCNN.csproj.nuget.g.targets │ │ │ ├── project.assets.json │ │ │ └── project.nuget.cache │ └── mnist.npz ├── F# │ ├── CNN │ │ ├── CNN.sln │ │ └── CNN │ │ │ ├── CNN.fsproj │ │ │ ├── Program.fs │ │ │ └── obj │ │ │ ├── CNN.fsproj.nuget.dgspec.json │ │ │ ├── CNN.fsproj.nuget.g.props │ │ │ ├── CNN.fsproj.nuget.g.targets │ │ │ ├── project.assets.json │ │ │ └── project.nuget.cache │ ├── DNN │ │ ├── DNN.sln │ │ └── DNN │ │ │ ├── DNN.fsproj │ │ │ ├── Program.fs │ │ │ └── obj │ │ │ ├── DNN.fsproj.nuget.dgspec.json │ │ │ ├── DNN.fsproj.nuget.g.props │ │ │ ├── DNN.fsproj.nuget.g.targets │ │ │ ├── project.assets.json │ │ │ └── project.nuget.cache │ ├── FSharpExamples │ │ ├── BasicOperations │ │ │ ├── BasicOperations.fsproj │ │ │ ├── Program.fs │ │ │ └── obj │ │ │ │ ├── BasicOperations.fsproj.nuget.dgspec.json │ │ │ │ ├── BasicOperations.fsproj.nuget.g.props │ │ │ │ ├── BasicOperations.fsproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ ├── FSharpExamples.sln │ │ └── FSharpExamples │ │ │ ├── HelloWorld.fsproj │ │ │ ├── Program.fs │ │ │ └── obj │ │ │ ├── FSharpExamples.fsproj.nuget.dgspec.json │ │ │ ├── FSharpExamples.fsproj.nuget.g.props │ │ │ ├── FSharpExamples.fsproj.nuget.g.targets │ │ │ ├── HelloWorld.fsproj.nuget.dgspec.json │ │ │ ├── HelloWorld.fsproj.nuget.g.props │ │ │ ├── HelloWorld.fsproj.nuget.g.targets │ │ │ ├── project.assets.json │ │ │ └── project.nuget.cache │ ├── LinearRegression │ │ ├── LinearRegression.sln │ │ └── LinearRegression │ │ │ ├── LinearRegression.fsproj │ │ │ ├── Program.fs │ │ │ └── obj │ │ │ ├── LinearRegression.fsproj.nuget.dgspec.json │ │ │ ├── LinearRegression.fsproj.nuget.g.props │ │ │ ├── LinearRegression.fsproj.nuget.g.targets │ │ │ ├── project.assets.json │ │ │ └── project.nuget.cache │ └── LogisticRegression │ │ ├── LogisticRegression.sln │ │ └── LogisticRegression │ │ ├── LogisticRegression.fsproj │ │ ├── Program.fs │ │ └── obj │ │ ├── LogisticRegression.fsproj.nuget.dgspec.json │ │ ├── LogisticRegression.fsproj.nuget.g.props │ │ ├── LogisticRegression.fsproj.nuget.g.targets │ │ ├── project.assets.json │ │ └── project.nuget.cache ├── Keras API │ └── LinearRegression_CustomModel │ │ ├── LinearRegression.sln │ │ └── LinearRegression │ │ ├── LinearRegression.csproj │ │ └── Program.cs ├── LinearRegression │ ├── LinearRegression.sln │ └── LinearRegression │ │ ├── LinearRegression.csproj │ │ └── Program.cs ├── LogisticRegression │ ├── .vs │ │ ├── LogisticRegression │ │ │ ├── DesignTimeBuild │ │ │ │ └── .dtbcache.v2 │ │ │ ├── FileContentIndex │ │ │ │ ├── fac7e505-aa1d-4e61-89da-00667604a095.vsidx │ │ │ │ └── read.lock │ │ │ └── v17 │ │ │ │ ├── .futdcache.v2 │ │ │ │ └── .suo │ │ └── ProjectEvaluation │ │ │ ├── logisticregression.metadata.v5.1 │ │ │ └── logisticregression.projects.v5.1 │ ├── LogisticRegression.sln │ └── LogisticRegression │ │ ├── LogisticRegression.csproj │ │ ├── Program.cs │ │ └── obj │ │ ├── Debug │ │ └── netcoreapp3.1 │ │ │ ├── .NETCoreApp,Version=v3.1.AssemblyAttributes.cs │ │ │ ├── LogisticRegression.AssemblyInfo.cs │ │ │ ├── LogisticRegression.AssemblyInfoInputs.cache │ │ │ ├── LogisticRegression.GeneratedMSBuildEditorConfig.editorconfig │ │ │ ├── LogisticRegression.assets.cache │ │ │ └── LogisticRegression.csproj.AssemblyReference.cache │ │ ├── LogisticRegression.csproj.nuget.dgspec.json │ │ ├── LogisticRegression.csproj.nuget.g.props │ │ ├── LogisticRegression.csproj.nuget.g.targets │ │ ├── project.assets.json │ │ └── project.nuget.cache ├── MnistCNNKerasFunctional │ ├── MnistCNNKerasFunctional.sln │ └── MnistCNNKerasFunctional │ │ ├── MnistCNNKerasFunctional.csproj │ │ ├── Program.cs │ │ └── obj │ │ ├── MnistCNNKerasFunctional.csproj.nuget.dgspec.json │ │ ├── MnistCNNKerasFunctional.csproj.nuget.g.props │ │ ├── MnistCNNKerasFunctional.csproj.nuget.g.targets │ │ ├── project.assets.json │ │ └── project.nuget.cache ├── TensorDebuggerVisualizersTest │ ├── TensorDebuggerVisualizersTest.sln │ └── TensorDebuggerVisualizersTest │ │ ├── Program.cs │ │ ├── TensorDebuggerVisualizersTest.csproj │ │ └── obj │ │ ├── TensorDebuggerVisualizersTest.csproj.nuget.dgspec.json │ │ ├── TensorDebuggerVisualizersTest.csproj.nuget.g.props │ │ ├── TensorDebuggerVisualizersTest.csproj.nuget.g.targets │ │ ├── project.assets.json │ │ └── project.nuget.cache ├── TransferLearningWithInceptionV3 │ ├── TransferLearningWithInceptionV3.sln │ └── TransferLearningWithInceptionV3 │ │ ├── Program.cs │ │ ├── TransferLearningWithInceptionV3.csproj │ │ └── obj │ │ ├── TransferLearningWithInceptionV3.csproj.nuget.dgspec.json │ │ ├── TransferLearningWithInceptionV3.csproj.nuget.g.props │ │ ├── TransferLearningWithInceptionV3.csproj.nuget.g.targets │ │ ├── project.assets.json │ │ └── project.nuget.cache ├── YOLOv3_Test │ ├── YOLOv3_Test.sln │ └── YOLOv3_Test │ │ ├── Program.cs │ │ ├── TestImage.cs │ │ ├── TestVideo.cs │ │ ├── YOLOv3.cs │ │ ├── YOLOv3_Test.csproj │ │ └── obj │ │ ├── YOLOv3_Test.csproj.nuget.dgspec.json │ │ ├── YOLOv3_Test.csproj.nuget.g.props │ │ ├── YOLOv3_Test.csproj.nuget.g.targets │ │ ├── project.assets.json │ │ └── project.nuget.cache ├── YoloV3_train │ ├── YoloV3_train.sln │ └── YoloV3_train │ │ ├── Core │ │ ├── Backbone.cs │ │ ├── BatchFeedingImage.cs │ │ ├── Common.cs │ │ ├── LabelBorderBox.cs │ │ ├── Utils.cs │ │ ├── YOLOv3.cs │ │ ├── YoloConfig.cs │ │ └── YoloDataset.cs │ │ ├── Program.cs │ │ ├── SampleYOLOv3.cs │ │ ├── YoloV3_train.csproj │ │ └── obj │ │ ├── YoloV3_train.csproj.nuget.dgspec.json │ │ ├── YoloV3_train.csproj.nuget.g.props │ │ ├── YoloV3_train.csproj.nuget.g.targets │ │ ├── project.assets.json │ │ └── project.nuget.cache └── word2vec │ ├── word2vec.sln │ └── word2vec │ ├── Program.cs │ ├── obj │ ├── project.assets.json │ ├── project.nuget.cache │ ├── word2vec.csproj.nuget.dgspec.json │ ├── word2vec.csproj.nuget.g.props │ └── word2vec.csproj.nuget.g.targets │ └── word2vec.csproj ├── LICENSE ├── README.md └── docs ├── .nojekyll ├── README.md ├── _images ├── Automatic-Differentiation.png ├── FIFOQueue-example.jpg ├── column-major-order.png ├── constant │ ├── n-index-formula-offset.svg │ └── n-index-formula.svg ├── contiguous-block-of-memory-ndarray-example-1.png ├── contiguous-block-of-memory.png ├── front-cover.jpg ├── gradient-descent.png ├── linear-regression-tensor-board.png ├── logistic-regression │ └── 1557035393445.png ├── minimize-square-cost.png ├── new-project-console.png ├── new-project.png ├── regression-dataset.png ├── row-major-order.png ├── sigmoid.png ├── tensor-constant-ndarray.png ├── tensor-naming.png └── tf.net.logo.png ├── _media ├── Cover.psd ├── Logo.md ├── TIM.jpg ├── TensorBoard-nn.png ├── WeChatCollection.jpg ├── cnn-result.png ├── cnn.png ├── csharp-vs-python-speed.mp4 ├── csharp_vs_python_speed_memory.jpg ├── eager-mode-add.png ├── favicon.ico ├── graph_vis_animation.gif ├── mnist.png ├── nn-result.png ├── nn.png ├── performance-comparison.jpg ├── syntax-comparision.png ├── tensors_flowing.gif ├── tf.net.architecture.svg ├── tf.net.icon-purple.svg ├── tf.net.icon-purple128.png ├── tf.net.icon-purple512.png ├── tf.net.icon-transparent.svg ├── tf.net.icon-transparent128.png ├── tf.net.icon-transparent512.png ├── tf.net.logo.png ├── tf.net.logo.svg ├── tf.net.logo512.png ├── tf2.jpg └── tf2.psd ├── _navbar.md ├── _scripts └── make-sidebar.py ├── _sidebar.md ├── api ├── tf.md └── tf.nn.md ├── components ├── Constant.md ├── ConvolutionNeuralNetwork.md ├── EagerMode.md ├── Foreword.md ├── FrontCover.md ├── Gradient.md ├── Graph.md ├── LinearRegression.md ├── LogisticRegression.md ├── NearestNeighbor.md ├── NeuralNetwork.md ├── Operation.md ├── Placeholder.md ├── Preface.md ├── Queue.md ├── Session.md ├── Table of Contents.md ├── Train.md ├── Variable.md └── tensor.md ├── contribute ├── contact.md └── contribute.md ├── essentials ├── installation.md ├── installationTroubleshooting.md ├── introduction.md └── tips.md ├── index.html ├── tutorials ├── HelloWorld.md ├── ImageRecognition.md ├── MnistInRnn.md └── examples.md └── zh-cn ├── README.md ├── _sidebar.md ├── contribute ├── contact.md └── contribute.md ├── essentials ├── installation.md ├── introduction.md └── tips.md └── tutorials └── examples.md /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/CnnTextClassification/CnnTextClassification.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31410.357 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CnnTextClassification", "CnnTextClassification\CnnTextClassification.csproj", "{CC76FC07-26AF-4D8D-A777-31E011FBEF97}" 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 | {CC76FC07-26AF-4D8D-A777-31E011FBEF97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {CC76FC07-26AF-4D8D-A777-31E011FBEF97}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {CC76FC07-26AF-4D8D-A777-31E011FBEF97}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {CC76FC07-26AF-4D8D-A777-31E011FBEF97}.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 = {AF1686A3-84F3-4904-A49B-5A6EEFDF7AC5} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/CnnTextClassification/CnnTextClassification/CnnTextClassification.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/CnnTextClassification/CnnTextClassification/obj/CnnTextClassification.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/CnnTextClassification/CnnTextClassification/obj/CnnTextClassification.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/CnnTextClassification/CnnTextClassification/obj/Debug/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/CnnTextClassification/CnnTextClassification/obj/Debug/net5.0/CnnTextClassification.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("CnnTextClassification")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("CnnTextClassification")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("CnnTextClassification")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // 由 MSBuild WriteCodeFragment 类生成。 23 | 24 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/CnnTextClassification/CnnTextClassification/obj/Debug/net5.0/CnnTextClassification.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 0c136f006e9ae3b29544988013830944ce87f9ec 2 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/CnnTextClassification/CnnTextClassification/obj/Debug/net5.0/CnnTextClassification.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.InvariantGlobalization = 7 | build_property.PlatformNeutralAssembly = 8 | build_property._SupportedPlatformList = Linux,macOS,Windows 9 | build_property.RootNamespace = CnnTextClassification 10 | build_property.ProjectDir = D:\SciSharp\出版相关\《TensorFlow.NET实战》代码案例资源\CnnTextClassification\CnnTextClassification\ 11 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/CnnTextClassification/CnnTextClassification/obj/Debug/net5.0/CnnTextClassification.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/CnnTextClassification/CnnTextClassification/obj/Debug/net5.0/CnnTextClassification.assets.cache -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/CnnTextClassification/CnnTextClassification/obj/Debug/net5.0/CnnTextClassification.csproj.AssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/CnnTextClassification/CnnTextClassification/obj/Debug/net5.0/CnnTextClassification.csproj.AssemblyReference.cache -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DCGAN/DCGAN.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31424.327 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DCGAN", "DCGAN\DCGAN.csproj", "{7AEE045C-4A32-4B4D-B7E9-D49786D7911A}" 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 | {7AEE045C-4A32-4B4D-B7E9-D49786D7911A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {7AEE045C-4A32-4B4D-B7E9-D49786D7911A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {7AEE045C-4A32-4B4D-B7E9-D49786D7911A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {7AEE045C-4A32-4B4D-B7E9-D49786D7911A}.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 = {EAB657D3-65B0-45B1-94C4-2A6874E93949} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DCGAN/DCGAN/DCGAN.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DCGAN/DCGAN/obj/DCGAN.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 | 25 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DCGAN/DCGAN/obj/DCGAN.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Eager/DNN_Eager.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30225.117 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DNN_Eager", "DNN_Eager\DNN_Eager.csproj", "{AD194F61-1F6F-4768-AB4F-26F733626289}" 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 | {AD194F61-1F6F-4768-AB4F-26F733626289}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {AD194F61-1F6F-4768-AB4F-26F733626289}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {AD194F61-1F6F-4768-AB4F-26F733626289}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {AD194F61-1F6F-4768-AB4F-26F733626289}.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 = {A2592E7F-CE7B-4766-BEE3-045AB850B81E} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Eager/DNN_Eager/DNN_Eager.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Keras/DNN_Keras.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30225.117 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DNN_Keras", "DNN_Keras\DNN_Keras.csproj", "{DAA66884-C2A9-439A-896B-779A218E7CFF}" 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 | {DAA66884-C2A9-439A-896B-779A218E7CFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {DAA66884-C2A9-439A-896B-779A218E7CFF}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {DAA66884-C2A9-439A-896B-779A218E7CFF}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {DAA66884-C2A9-439A-896B-779A218E7CFF}.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 = {71FFF163-CE4D-4ABE-A5CE-04889236C0A7} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Keras/DNN_Keras/DNN_Keras.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Keras/DNN_Keras/obj/DNN_Keras.csproj.nuget.dgspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "format": 1, 3 | "restore": { 4 | "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\DNN_Keras\\DNN_Keras\\DNN_Keras.csproj": {} 5 | }, 6 | "projects": { 7 | "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\DNN_Keras\\DNN_Keras\\DNN_Keras.csproj": { 8 | "version": "1.0.0", 9 | "restore": { 10 | "projectUniqueName": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\DNN_Keras\\DNN_Keras\\DNN_Keras.csproj", 11 | "projectName": "DNN_Keras", 12 | "projectPath": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\DNN_Keras\\DNN_Keras\\DNN_Keras.csproj", 13 | "packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\", 14 | "outputPath": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\DNN_Keras\\DNN_Keras\\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 | "netcoreapp3.1" 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 | "netcoreapp3.1": { 37 | "targetAlias": "netcoreapp3.1", 38 | "projectReferences": {} 39 | } 40 | }, 41 | "warningProperties": { 42 | "warnAsError": [ 43 | "NU1605" 44 | ] 45 | } 46 | }, 47 | "frameworks": { 48 | "netcoreapp3.1": { 49 | "targetAlias": "netcoreapp3.1", 50 | "dependencies": { 51 | "SciSharp.TensorFlow.Redist": { 52 | "target": "Package", 53 | "version": "[2.3.0, )" 54 | }, 55 | "TensorFlow.NET": { 56 | "target": "Package", 57 | "version": "[0.20.0-preview4, )" 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.201\\RuntimeIdentifierGraph.json" 76 | } 77 | } 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Keras/DNN_Keras/obj/DNN_Keras.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 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Keras/DNN_Keras/obj/DNN_Keras.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Keras/DNN_Keras/obj/project.nuget.cache: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "dgSpecHash": "WlxFPQ1gE/PkZYxCtJnK28NGq9LB9B5lg2X3UaKt6sl8VTcA2T9yZE5QQHQ+kJTCOfLeMUp1ceknZBkEiLO6KQ==", 4 | "success": true, 5 | "projectFilePath": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\DNN_Keras\\DNN_Keras\\DNN_Keras.csproj", 6 | "expectedPackageFiles": [ 7 | "C:\\Users\\Administrator\\.nuget\\packages\\google.protobuf\\3.11.4\\google.protobuf.3.11.4.nupkg.sha512", 8 | "C:\\Users\\Administrator\\.nuget\\packages\\numsharp.lite\\0.1.7\\numsharp.lite.0.1.7.nupkg.sha512", 9 | "C:\\Users\\Administrator\\.nuget\\packages\\protobuf.text\\0.4.0\\protobuf.text.0.4.0.nupkg.sha512", 10 | "C:\\Users\\Administrator\\.nuget\\packages\\scisharp.tensorflow.redist\\2.3.0\\scisharp.tensorflow.redist.2.3.0.nupkg.sha512", 11 | "C:\\Users\\Administrator\\.nuget\\packages\\system.memory\\4.5.3\\system.memory.4.5.3.nupkg.sha512", 12 | "C:\\Users\\Administrator\\.nuget\\packages\\tensorflow.net\\0.20.0-preview4\\tensorflow.net.0.20.0-preview4.nupkg.sha512" 13 | ], 14 | "logs": [] 15 | } -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Keras_Functional/DNN_Keras_Functional.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30225.117 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DNN_Keras_Functional", "DNN_Keras_Functional\DNN_Keras_Functional.csproj", "{E22A55C7-BEFE-4CE1-A948-A06462EE3969}" 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 | {E22A55C7-BEFE-4CE1-A948-A06462EE3969}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {E22A55C7-BEFE-4CE1-A948-A06462EE3969}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {E22A55C7-BEFE-4CE1-A948-A06462EE3969}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {E22A55C7-BEFE-4CE1-A948-A06462EE3969}.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 = {2E1E3A98-86BB-4F64-B61D-259EABE703C4} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Keras_Functional/DNN_Keras_Functional/DNN_Keras_Functional.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Keras_Functional/DNN_Keras_Functional/Program.cs: -------------------------------------------------------------------------------- 1 | using NumSharp; 2 | using System; 3 | using Tensorflow.Keras.Engine; 4 | using static Tensorflow.KerasApi; 5 | using Tensorflow.Keras.Layers; 6 | 7 | namespace DNN_Keras_Functional 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | DNN_Keras_Functional dnn = new DNN_Keras_Functional(); 14 | dnn.Main(); 15 | } 16 | class DNN_Keras_Functional 17 | { 18 | Model model; 19 | NDArray x_train, y_train, x_test, y_test; 20 | LayersApi layers = new LayersApi(); 21 | public void Main() 22 | { 23 | //1. prepare data 24 | (x_train, y_train, x_test, y_test) = keras.datasets.mnist.load_data(); 25 | x_train = x_train.reshape(60000, 784) / 255f; 26 | x_test = x_test.reshape(10000, 784) / 255f; 27 | 28 | //2. buid model 29 | var inputs = keras.Input(shape: 784);// input layer 30 | var outputs = layers.Dense(64, activation: keras.activations.Relu).Apply(inputs);// 1st dense layer 31 | outputs = layers.Dense(64, activation: keras.activations.Relu).Apply(outputs);// 2nd dense layer 32 | outputs = layers.Dense(10).Apply(outputs);// output layer 33 | model = keras.Model(inputs, outputs, name: "mnist_model");// build keras model 34 | model.summary();// show model summary 35 | model.compile(loss: keras.losses.SparseCategoricalCrossentropy(from_logits: true), 36 | optimizer: keras.optimizers.RMSprop(), 37 | metrics: new[] { "accuracy" });// compile keras model into tensorflow's static graph 38 | 39 | //3. train model by feeding data and labels. 40 | model.fit(x_train, y_train, batch_size: 64, epochs: 2, validation_split: 0.2f); 41 | 42 | //4. evluate the model 43 | model.evaluate(x_test, y_test, verbose: 2); 44 | 45 | //5. save and serialize model 46 | model.save("mnist_model"); 47 | 48 | // reload the exact same model purely from the file: 49 | // model = keras.models.load_model("path_to_my_model"); 50 | 51 | Console.ReadKey(); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Keras_Functional/DNN_Keras_Functional/obj/DNN_Keras_Functional.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:\Microsoft\Xamarin\NuGet\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder 9 | PackageReference 10 | 5.8.1 11 | 12 | 13 | 14 | 15 | 16 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/DNN_Keras_Functional/DNN_Keras_Functional/obj/DNN_Keras_Functional.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/ExploreCNN/ExploreCNN.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31112.23 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExploreCNN", "ExploreCNN\ExploreCNN.csproj", "{7BE48959-EC1B-466A-A807-0767A330A06C}" 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 | {7BE48959-EC1B-466A-A807-0767A330A06C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {7BE48959-EC1B-466A-A807-0767A330A06C}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {7BE48959-EC1B-466A-A807-0767A330A06C}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {7BE48959-EC1B-466A-A807-0767A330A06C}.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 = {6CD64E57-ED4F-49A7-94D2-4381E1F70945} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/ExploreCNN/ExploreCNN/ExploreCNN.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net5.0-windows 6 | true 7 | 8 | 9 | 10 | x64 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/ExploreCNN/ExploreCNN/ExploreCNN.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Form 6 | 7 | 8 | Component 9 | 10 | 11 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/ExploreCNN/ExploreCNN/Form1.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | text/microsoft-resx 50 | 51 | 52 | 2.0 53 | 54 | 55 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 56 | 57 | 58 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 59 | 60 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/ExploreCNN/ExploreCNN/ImageBox.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing.Drawing2D; 2 | 3 | namespace System.Windows.Forms 4 | { 5 | public partial class ImageBox : PictureBox 6 | { 7 | protected override void OnPaint(PaintEventArgs pe) 8 | { 9 | var g = pe.Graphics; 10 | g.InterpolationMode = InterpolationMode.NearestNeighbor; 11 | g.SmoothingMode = SmoothingMode.None; 12 | g.PixelOffsetMode = PixelOffsetMode.Half; 13 | base.OnPaint(pe); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/ExploreCNN/ExploreCNN/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace ExploreCNN 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.SetHighDpiMode(HighDpiMode.SystemAware); 18 | Application.EnableVisualStyles(); 19 | Application.SetCompatibleTextRenderingDefault(false); 20 | Application.Run(new Form1()); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/ExploreCNN/ExploreCNN/obj/ExploreCNN.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 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/ExploreCNN/ExploreCNN/obj/ExploreCNN.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/ExploreCNN/mnist.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/ExploreCNN/mnist.npz -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/CNN/CNN.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31410.357 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "CNN", "CNN\CNN.fsproj", "{86DB4B9D-925A-4127-9699-9E538D014659}" 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 | {86DB4B9D-925A-4127-9699-9E538D014659}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {86DB4B9D-925A-4127-9699-9E538D014659}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {86DB4B9D-925A-4127-9699-9E538D014659}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {86DB4B9D-925A-4127-9699-9E538D014659}.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 = {4CAD6CF9-73EF-46FD-9E5C-1F21759E5AD8} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/CNN/CNN/CNN.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net5.0 6 | 3390;$(WarnOn) 7 | 8 | 9 | 10 | x64 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/CNN/CNN/Program.fs: -------------------------------------------------------------------------------- 1 | open System.IO 2 | open Tensorflow 3 | open Tensorflow.Keras 4 | open Tensorflow.Keras.Engine 5 | open Tensorflow.Keras.Utils 6 | open type Tensorflow.Binding 7 | open type Tensorflow.KerasApi 8 | 9 | let batch_size = 32 10 | let epochs = 3 11 | let img_dim = Shape (180, 180) 12 | 13 | let private prepareData () = 14 | let fileName = "flower_photos.tgz" 15 | let url = $"https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz" 16 | let data_dir = Path.Combine(Path.GetTempPath(), "flower_photos") 17 | Web.Download(url, data_dir, fileName) |> ignore 18 | Compress.ExtractTGZ(Path.Join(data_dir, fileName), data_dir) 19 | let data_dir = Path.Combine(data_dir, "flower_photos") 20 | 21 | // convert to tensor 22 | let train_ds = 23 | keras.preprocessing.image_dataset_from_directory( 24 | data_dir, 25 | validation_split = 0.2f, 26 | subset = "training", 27 | seed = 123, 28 | image_size = img_dim, 29 | batch_size = batch_size) 30 | 31 | let val_ds = 32 | keras.preprocessing.image_dataset_from_directory( 33 | data_dir, 34 | validation_split = 0.2f, 35 | subset = "validation", 36 | seed = 123, 37 | image_size = img_dim, 38 | batch_size = batch_size) 39 | 40 | let train_ds = train_ds.shuffle(1000).prefetch(buffer_size = -1) 41 | let val_ds = val_ds.prefetch(buffer_size = -1) 42 | 43 | for img, label in train_ds do 44 | print($"images: {img.TensorShape}") 45 | print($"labels: {label.numpy()}") 46 | 47 | train_ds, val_ds 48 | 49 | let private buildModel () = 50 | let num_classes = 5 51 | let layers = keras.layers 52 | let model = keras.Sequential(ResizeArray(seq { 53 | layers.Rescaling(1.0f / 255f, input_shape = Shape ((int)img_dim.dims.[0], (int)img_dim.dims.[1], 3)) :> ILayer; 54 | layers.Conv2D(16, Shape 3, padding = "same", activation = keras.activations.Relu); 55 | layers.MaxPooling2D(); 56 | //layers.Conv2D(32, Shape 3, padding = "same", activation = keras.activations.Relu); 57 | //layers.MaxPooling2D(); 58 | //layers.Conv2D(64, Shape 3, padding = "same", activation = keras.activations.Relu); 59 | //layers.MaxPooling2D(); 60 | layers.Flatten(); 61 | layers.Dense(128, activation = keras.activations.Relu); 62 | layers.Dense(num_classes) })) 63 | 64 | model.compile( 65 | optimizer = keras.optimizers.Adam(), 66 | loss = keras.losses.SparseCategoricalCrossentropy(from_logits = true), 67 | metrics = [| "accuracy" |]) 68 | 69 | model.summary() 70 | model 71 | 72 | let private train train_ds val_ds (model : Sequential) = 73 | model.fit(train_ds, validation_data = val_ds, epochs = epochs) 74 | 75 | let private run () = 76 | let train_ds, val_ds = prepareData() 77 | let model = buildModel() 78 | train train_ds val_ds model 79 | 80 | run() -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/CNN/CNN/obj/CNN.fsproj.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 | 25 | C:\Users\Administrator\.nuget\packages\tensorflow.keras\0.6.3 26 | C:\Users\Administrator\.nuget\packages\scisharp.tensorflow.redist\2.6.0 27 | C:\Users\Administrator\.nuget\packages\fsharp.core\5.0.0 28 | 29 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/CNN/CNN/obj/CNN.fsproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/DNN/DNN.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31410.357 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "DNN", "DNN\DNN.fsproj", "{6F18519F-A66C-4F93-BAA9-F3DE68C4C385}" 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 | {6F18519F-A66C-4F93-BAA9-F3DE68C4C385}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {6F18519F-A66C-4F93-BAA9-F3DE68C4C385}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {6F18519F-A66C-4F93-BAA9-F3DE68C4C385}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {6F18519F-A66C-4F93-BAA9-F3DE68C4C385}.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 = {2B0A02A3-958B-406F-98F8-57115247B0E0} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/DNN/DNN/DNN.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net5.0 6 | 3390;$(WarnOn) 7 | 8 | 9 | 10 | x64 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/DNN/DNN/Program.fs: -------------------------------------------------------------------------------- 1 | open NumSharp 2 | open Tensorflow 3 | open Tensorflow.Keras.Engine 4 | open Tensorflow.Keras.Layers 5 | open type Tensorflow.KerasApi 6 | 7 | type Tensor with 8 | member x.asTensors : Tensors = new Tensors([| x |]) 9 | 10 | let prepareData () = 11 | let (x_train, y_train, x_test, y_test) = keras.datasets.mnist.load_data().Deconstruct() 12 | let x_train = x_train.reshape(60000, 784) / 255f 13 | let x_test = x_test.reshape(10000, 784) / 255f 14 | (x_train, y_train, x_test, y_test) 15 | 16 | let buildModel () = 17 | // input layer 18 | let inputs = keras.Input(shape = TensorShape 784) 19 | 20 | let layers = LayersApi() 21 | 22 | // 1st dense layer 23 | let outputs = layers.Dense(64, activation = keras.activations.Relu).Apply(inputs.asTensors) 24 | 25 | // 2nd dense layer 26 | let outputs = layers.Dense(64, activation = keras.activations.Relu).Apply(outputs) 27 | 28 | // output layer 29 | let outputs = layers.Dense(10).Apply(outputs) 30 | 31 | // build keras model 32 | let model = keras.Model(inputs.asTensors, outputs, name = "mnist_model") 33 | // show model summary 34 | model.summary() 35 | 36 | // compile keras model into tensorflow's static graph 37 | model.compile( 38 | loss = keras.losses.SparseCategoricalCrossentropy(from_logits = true), 39 | optimizer = keras.optimizers.RMSprop(), 40 | metrics = [| "accuracy" |]) 41 | 42 | model 43 | 44 | let private train (x_train : NDArray, y_train) (x_test : NDArray, y_test) (model : Functional) = 45 | // train model by feeding data and labels. 46 | model.fit(x_train, y_train, batch_size = 64, epochs = 2, validation_split = 0.2f) 47 | 48 | // evluate the model 49 | model.evaluate(x_test, y_test, verbose = 2) 50 | 51 | // save and serialize model 52 | model.save("mnist_model") 53 | 54 | // recreate the exact same model purely from the file: 55 | // model = keras.models.load_model("mnist_model") 56 | 57 | let private run () = 58 | let (x_train, y_train, x_test, y_test) = prepareData() 59 | let model = buildModel() 60 | train (x_train, y_train) (x_test, y_test) model 61 | 62 | run() -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/DNN/DNN/obj/DNN.fsproj.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 | 25 | C:\Users\Administrator\.nuget\packages\tensorflow.keras\0.5.1 26 | C:\Users\Administrator\.nuget\packages\scisharp.tensorflow.redist\2.4.1 27 | C:\Users\Administrator\.nuget\packages\fsharp.core\5.0.0 28 | 29 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/DNN/DNN/obj/DNN.fsproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/BasicOperations/BasicOperations.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net5.0 6 | 3390;$(WarnOn) 7 | 8 | 9 | 10 | x64 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/BasicOperations/Program.fs: -------------------------------------------------------------------------------- 1 | open type Tensorflow.Binding 2 | 3 | let private run() = 4 | 5 | // Define tensor constants. 6 | let a = tf.constant(2) 7 | let b = tf.constant(3) 8 | let c = tf.constant(5) 9 | 10 | // Various tensor operations. 11 | // Note: Tensors also support operators (+, *, ...) 12 | let add = tf.add(a, b) 13 | let sub = tf.subtract(a, b) 14 | let mul = tf.multiply(a, b) 15 | let div = tf.divide(a, b) 16 | 17 | // Access tensors value. 18 | print("add =", add.numpy()) 19 | print("sub =", sub.numpy()) 20 | print("mul =", mul.numpy()) 21 | print("div =", div.numpy()) 22 | 23 | // Some more operations. 24 | let mean = tf.reduce_mean([| a; b; c |]) 25 | let sum = tf.reduce_sum([| a; b; c |]) 26 | 27 | // Access tensors value. 28 | print("mean =", mean.numpy()) 29 | print("sum =", sum.numpy()) 30 | 31 | // Matrix multiplications. 32 | let matrix1 = tf.constant(array2D [ [ 1; 2 ]; [ 3; 4 ] ]) 33 | let matrix2 = tf.constant(array2D [ [ 5; 6 ]; [ 7; 8 ] ]) 34 | let product = tf.matmul(matrix1, matrix2) 35 | // Convert Tensor to Numpy. 36 | print("product =", product.numpy()) 37 | 38 | run() -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/BasicOperations/obj/BasicOperations.fsproj.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 | 25 | C:\Users\Administrator\.nuget\packages\tensorflow.keras\0.5.1 26 | C:\Users\Administrator\.nuget\packages\scisharp.tensorflow.redist\2.4.1 27 | C:\Users\Administrator\.nuget\packages\fsharp.core\5.0.0 28 | 29 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/BasicOperations/obj/BasicOperations.fsproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/FSharpExamples.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31410.357 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "HelloWorld", "FSharpExamples\HelloWorld.fsproj", "{FAD66799-BFB1-4D57-848C-D4C9DA71D2FA}" 7 | EndProject 8 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BasicOperations", "BasicOperations\BasicOperations.fsproj", "{1E6E91AA-C96A-4A68-B094-CF7D9052EFAE}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {FAD66799-BFB1-4D57-848C-D4C9DA71D2FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {FAD66799-BFB1-4D57-848C-D4C9DA71D2FA}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {FAD66799-BFB1-4D57-848C-D4C9DA71D2FA}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {FAD66799-BFB1-4D57-848C-D4C9DA71D2FA}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {1E6E91AA-C96A-4A68-B094-CF7D9052EFAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {1E6E91AA-C96A-4A68-B094-CF7D9052EFAE}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {1E6E91AA-C96A-4A68-B094-CF7D9052EFAE}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {1E6E91AA-C96A-4A68-B094-CF7D9052EFAE}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {3849B692-D1D1-4367-B354-7B165E7C2830} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/FSharpExamples/HelloWorld.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net5.0 6 | 3390;$(WarnOn) 7 | 8 | 9 | 10 | x64 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/FSharpExamples/Program.fs: -------------------------------------------------------------------------------- 1 | open NumSharp 2 | open type Tensorflow.Binding 3 | 4 | // A very simple "hello world" using TensorFlow v2 tensors. 5 | let private run () = 6 | // Eager model is enabled by default. 7 | //tf.enable_eager_execution() 8 | 9 | (* Create a Constant op 10 | The op is added as a node to the default graph. 11 | 12 | The value returned by the constructor represents the output 13 | of the Constant op. *) 14 | let str = "Hello, TensorFlow.NET!" 15 | let hello = tf.constant(str) 16 | 17 | // tf.Tensor: shape=(), dtype=string, numpy=b'Hello, TensorFlow.NET!' 18 | //print(hello); 19 | 20 | let hello_str = NDArray.AsStringArray(hello.numpy()).[0] 21 | 22 | print(hello_str) 23 | 24 | run() -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/FSharpExamples/obj/FSharpExamples.fsproj.nuget.dgspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "format": 1, 3 | "restore": { 4 | "D:\\SciSharp\\TensorFlow.NET-Tutorials\\PracticeCode\\F#\\FSharpExamples\\FSharpExamples\\FSharpExamples.fsproj": {} 5 | }, 6 | "projects": { 7 | "D:\\SciSharp\\TensorFlow.NET-Tutorials\\PracticeCode\\F#\\FSharpExamples\\FSharpExamples\\FSharpExamples.fsproj": { 8 | "version": "1.0.0", 9 | "restore": { 10 | "projectUniqueName": "D:\\SciSharp\\TensorFlow.NET-Tutorials\\PracticeCode\\F#\\FSharpExamples\\FSharpExamples\\FSharpExamples.fsproj", 11 | "projectName": "FSharpExamples", 12 | "projectPath": "D:\\SciSharp\\TensorFlow.NET-Tutorials\\PracticeCode\\F#\\FSharpExamples\\FSharpExamples\\FSharpExamples.fsproj", 13 | "packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\", 14 | "outputPath": "D:\\SciSharp\\TensorFlow.NET-Tutorials\\PracticeCode\\F#\\FSharpExamples\\FSharpExamples\\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 | }, 42 | "frameworks": { 43 | "net5.0": { 44 | "targetAlias": "net5.0", 45 | "dependencies": { 46 | "FSharp.Core": { 47 | "include": "Runtime, Compile, Build, Native, Analyzers, BuildTransitive", 48 | "target": "Package", 49 | "version": "[5.0.0, )", 50 | "generatePathProperty": true 51 | } 52 | }, 53 | "imports": [ 54 | "net461", 55 | "net462", 56 | "net47", 57 | "net471", 58 | "net472", 59 | "net48" 60 | ], 61 | "assetTargetFallback": true, 62 | "warn": true, 63 | "frameworkReferences": { 64 | "Microsoft.NETCore.App": { 65 | "privateAssets": "all" 66 | } 67 | }, 68 | "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.301\\RuntimeIdentifierGraph.json" 69 | } 70 | } 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/FSharpExamples/obj/FSharpExamples.fsproj.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 | C:\Users\Administrator\.nuget\packages\fsharp.core\5.0.0 23 | 24 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/FSharpExamples/obj/FSharpExamples.fsproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/FSharpExamples/obj/HelloWorld.fsproj.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 | 25 | C:\Users\Administrator\.nuget\packages\tensorflow.keras\0.5.1 26 | C:\Users\Administrator\.nuget\packages\scisharp.tensorflow.redist\2.4.1 27 | C:\Users\Administrator\.nuget\packages\fsharp.core\5.0.0 28 | 29 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/FSharpExamples/FSharpExamples/obj/HelloWorld.fsproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/LinearRegression/LinearRegression.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31410.357 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "LinearRegression", "LinearRegression\LinearRegression.fsproj", "{0B677300-2AB1-4450-A9AD-CBAFBD1D9C7B}" 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 | {0B677300-2AB1-4450-A9AD-CBAFBD1D9C7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {0B677300-2AB1-4450-A9AD-CBAFBD1D9C7B}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {0B677300-2AB1-4450-A9AD-CBAFBD1D9C7B}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {0B677300-2AB1-4450-A9AD-CBAFBD1D9C7B}.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 = {AFC72D1C-8C69-4A7F-82F7-AD13937738EF} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/LinearRegression/LinearRegression/LinearRegression.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net5.0 6 | 3390;$(WarnOn) 7 | 8 | 9 | 10 | x64 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/LinearRegression/LinearRegression/Program.fs: -------------------------------------------------------------------------------- 1 | open NumSharp 2 | open type Tensorflow.Binding 3 | open type Tensorflow.KerasApi 4 | 5 | 6 | let private run() = 7 | 8 | let training_steps = 1000 9 | let learning_rate = 0.01f 10 | let display_step = 100 11 | 12 | let train_X = 13 | np.array(3.3f, 4.4f, 5.5f, 6.71f, 6.93f, 4.168f, 9.779f, 6.182f, 7.59f, 2.167f, 14 | 7.042f, 10.791f, 5.313f, 7.997f, 5.654f, 9.27f, 3.1f) 15 | let train_Y = 16 | np.array(1.7f, 2.76f, 2.09f, 3.19f, 1.694f, 1.573f, 3.366f, 2.596f, 2.53f, 1.221f, 17 | 2.827f, 3.465f, 1.65f, 2.904f, 2.42f, 2.94f, 1.3f) 18 | let n_samples = train_X.shape.[0] 19 | 20 | // We can set a fixed init value in order to demo 21 | let W = tf.Variable(-0.06f,name = "weight") 22 | let b = tf.Variable(-0.73f, name = "bias") 23 | let optimizer = keras.optimizers.SGD(learning_rate) 24 | 25 | // Run training for the given number of steps. 26 | for step = 1 to (training_steps + 1) do 27 | // Run the optimization to update W and b values. 28 | // Wrap computation inside a GradientTape for automatic differentiation. 29 | use g = tf.GradientTape() 30 | // Linear regression (Wx + b). 31 | let pred = W * train_X + b 32 | // Mean square error. 33 | let loss = tf.reduce_sum(tf.pow(pred - train_Y,2)) / (2 * n_samples) 34 | // should stop recording 35 | // compute gradients 36 | let gradients = g.gradient(loss,struct (W,b)) 37 | 38 | // Update W and b following gradients. 39 | optimizer.apply_gradients(zip(gradients, struct (W,b))) 40 | 41 | if (step % display_step) = 0 then 42 | let pred = W * train_X + b 43 | let loss = tf.reduce_sum(tf.pow(pred-train_Y,2)) / (2 * n_samples) 44 | printfn $"step: {step}, loss: {loss.numpy()}, W: {W.numpy()}, b: {b.numpy()}" 45 | 46 | run() -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/LinearRegression/LinearRegression/obj/LinearRegression.fsproj.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 | 25 | C:\Users\Administrator\.nuget\packages\tensorflow.keras\0.5.1 26 | C:\Users\Administrator\.nuget\packages\scisharp.tensorflow.redist\2.4.1 27 | C:\Users\Administrator\.nuget\packages\fsharp.core\5.0.0 28 | 29 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/LinearRegression/LinearRegression/obj/LinearRegression.fsproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/LogisticRegression/LogisticRegression.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31410.357 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "LogisticRegression", "LogisticRegression\LogisticRegression.fsproj", "{FC7980B2-8EE2-4252-B11E-C1F7924CE5F0}" 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 | {FC7980B2-8EE2-4252-B11E-C1F7924CE5F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {FC7980B2-8EE2-4252-B11E-C1F7924CE5F0}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {FC7980B2-8EE2-4252-B11E-C1F7924CE5F0}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {FC7980B2-8EE2-4252-B11E-C1F7924CE5F0}.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 = {C1442B71-C34C-453F-BC4C-9007B8BB9653} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/LogisticRegression/LogisticRegression/LogisticRegression.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net5.0 6 | 3390;$(WarnOn) 7 | 8 | 9 | 10 | x64 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/LogisticRegression/LogisticRegression/obj/LogisticRegression.fsproj.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 | 25 | C:\Users\Administrator\.nuget\packages\tensorflow.keras\0.5.1 26 | C:\Users\Administrator\.nuget\packages\scisharp.tensorflow.redist\2.4.1 27 | C:\Users\Administrator\.nuget\packages\fsharp.core\5.0.0 28 | 29 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/F#/LogisticRegression/LogisticRegression/obj/LogisticRegression.fsproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/Keras API/LinearRegression_CustomModel/LinearRegression.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30225.117 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinearRegression", "LinearRegression\LinearRegression.csproj", "{E9C2EA56-3DDB-451F-937B-BEAB123E3B72}" 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 | {E9C2EA56-3DDB-451F-937B-BEAB123E3B72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {E9C2EA56-3DDB-451F-937B-BEAB123E3B72}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {E9C2EA56-3DDB-451F-937B-BEAB123E3B72}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {E9C2EA56-3DDB-451F-937B-BEAB123E3B72}.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 = {0F754F82-F2DB-417F-9B4C-162B601FB5DD} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/Keras API/LinearRegression_CustomModel/LinearRegression/LinearRegression.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/Keras API/LinearRegression_CustomModel/LinearRegression/Program.cs: -------------------------------------------------------------------------------- 1 | using NumSharp; 2 | using System; 3 | using System.Linq; 4 | using Tensorflow; 5 | using Tensorflow.Keras; 6 | using Tensorflow.Keras.ArgsDefinition; 7 | using Tensorflow.Keras.Engine; 8 | using static Tensorflow.Binding; 9 | using static Tensorflow.KerasApi; 10 | 11 | namespace LinearRegression 12 | { 13 | class Program 14 | { 15 | static void Main(string[] args) 16 | { 17 | TFNET tfnet = new TFNET(); 18 | tfnet.Run(); 19 | } 20 | } 21 | public class TFNET 22 | { 23 | public void Run() 24 | { 25 | Tensor X = tf.constant(new[,] { { 1.0f, 2.0f, 3.0f }, { 4.0f, 5.0f, 6.0f } }); 26 | Tensor y = tf.constant(new[,] { { 10.0f }, { 20.0f } }); 27 | 28 | var model = new Linear(new ModelArgs()); 29 | var optimizer = keras.optimizers.SGD(learning_rate: 0.01f); 30 | foreach (var step in range(20))//20 iterations for test 31 | { 32 | using var g = tf.GradientTape(); 33 | var y_pred = model.Apply(X);//using "y_pred = model.Apply(X)" replace "y_pred = a * X + b" 34 | var loss = tf.reduce_mean(tf.square(y_pred - y)); 35 | var grads = g.gradient(loss, model.trainable_variables); 36 | optimizer.apply_gradients(zip(grads, model.trainable_variables.Select(x => x as ResourceVariable))); 37 | print($"step: {step},loss: {loss.numpy()}"); 38 | } 39 | print(model.trainable_variables.ToArray()); 40 | Console.ReadKey(); 41 | } 42 | } 43 | public class Linear : Model 44 | { 45 | Layer dense; 46 | public Linear(ModelArgs args) : base(args) 47 | { 48 | dense = keras.layers.Dense(1, activation: null, 49 | kernel_initializer: tf.zeros_initializer, bias_initializer: tf.zeros_initializer); 50 | StackLayers(dense); 51 | } 52 | // Set forward pass 53 | protected override Tensors Call(Tensors inputs, Tensor state = null, bool is_training = false) 54 | { 55 | var outputs = dense.Apply(inputs); 56 | return outputs; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LinearRegression/LinearRegression.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30225.117 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinearRegression", "LinearRegression\LinearRegression.csproj", "{E9C2EA56-3DDB-451F-937B-BEAB123E3B72}" 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 | {E9C2EA56-3DDB-451F-937B-BEAB123E3B72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {E9C2EA56-3DDB-451F-937B-BEAB123E3B72}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {E9C2EA56-3DDB-451F-937B-BEAB123E3B72}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {E9C2EA56-3DDB-451F-937B-BEAB123E3B72}.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 = {0F754F82-F2DB-417F-9B4C-162B601FB5DD} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LinearRegression/LinearRegression/LinearRegression.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LinearRegression/LinearRegression/Program.cs: -------------------------------------------------------------------------------- 1 | using NumSharp; 2 | using System; 3 | using static Tensorflow.Binding; 4 | 5 | namespace LinearRegression 6 | { 7 | class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | //1. Prepare data 12 | NDArray train_X = np.array(3.3f, 4.4f, 5.5f, 6.71f, 6.93f, 4.168f, 9.779f, 6.182f, 7.59f, 2.167f, 13 | 7.042f, 10.791f, 5.313f, 7.997f, 5.654f, 9.27f, 3.1f); 14 | NDArray train_Y = np.array(1.7f, 2.76f, 2.09f, 3.19f, 1.694f, 1.573f, 3.366f, 2.596f, 2.53f, 1.221f, 15 | 2.827f, 3.465f, 1.65f, 2.904f, 2.42f, 2.94f, 1.3f); 16 | int n_samples = train_X.shape[0]; 17 | 18 | //2. Set weights 19 | var W = tf.Variable(0f, name: "weight"); 20 | var b = tf.Variable(0f, name: "bias"); 21 | float learning_rate = 0.01f; 22 | var optimizer = tf.optimizers.SGD(learning_rate); 23 | 24 | //3. Run the optimization to update weights 25 | int training_steps = 1000; 26 | int display_step = 50; 27 | foreach (var step in range(1, training_steps + 1)) 28 | { 29 | using var g = tf.GradientTape(); 30 | // Linear regression (Wx + b). 31 | var pred = W * train_X + b; 32 | // MSE:Mean square error. 33 | var loss = tf.reduce_sum(tf.pow(pred - train_Y, 2)) / n_samples; 34 | var gradients = g.gradient(loss, (W, b)); 35 | 36 | // Update W and b following gradients. 37 | optimizer.apply_gradients(zip(gradients, (W, b))); 38 | if (step % display_step == 0) 39 | { 40 | pred = W * train_X + b; 41 | loss = tf.reduce_sum(tf.pow(pred - train_Y, 2)) / n_samples; 42 | print($"step: {step}, loss: {loss.numpy()}, W: {W.numpy()}, b: {b.numpy()}"); 43 | } 44 | } 45 | 46 | 47 | Console.ReadKey(); 48 | 49 | 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/.vs/LogisticRegression/DesignTimeBuild/.dtbcache.v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/LogisticRegression/.vs/LogisticRegression/DesignTimeBuild/.dtbcache.v2 -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/.vs/LogisticRegression/FileContentIndex/fac7e505-aa1d-4e61-89da-00667604a095.vsidx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/LogisticRegression/.vs/LogisticRegression/FileContentIndex/fac7e505-aa1d-4e61-89da-00667604a095.vsidx -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/.vs/LogisticRegression/FileContentIndex/read.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/LogisticRegression/.vs/LogisticRegression/FileContentIndex/read.lock -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/.vs/LogisticRegression/v17/.futdcache.v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/LogisticRegression/.vs/LogisticRegression/v17/.futdcache.v2 -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/.vs/LogisticRegression/v17/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/LogisticRegression/.vs/LogisticRegression/v17/.suo -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/.vs/ProjectEvaluation/logisticregression.metadata.v5.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/LogisticRegression/.vs/ProjectEvaluation/logisticregression.metadata.v5.1 -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/.vs/ProjectEvaluation/logisticregression.projects.v5.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/LogisticRegression/.vs/ProjectEvaluation/logisticregression.projects.v5.1 -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30225.117 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogisticRegression", "LogisticRegression\LogisticRegression.csproj", "{AC338C5C-33F5-4A16-A086-80DD38A599B2}" 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 | {AC338C5C-33F5-4A16-A086-80DD38A599B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {AC338C5C-33F5-4A16-A086-80DD38A599B2}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {AC338C5C-33F5-4A16-A086-80DD38A599B2}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {AC338C5C-33F5-4A16-A086-80DD38A599B2}.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 = {FA7429A9-4F48-46CB-A491-8F6C3831A09D} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/LogisticRegression.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/obj/Debug/netcoreapp3.1/LogisticRegression.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("LogisticRegression")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("LogisticRegression")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("LogisticRegression")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // 由 MSBuild WriteCodeFragment 类生成。 23 | 24 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/obj/Debug/netcoreapp3.1/LogisticRegression.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 2230c4fa00f0ed17836dab5fc7cc299419a66a3c 2 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/obj/Debug/netcoreapp3.1/LogisticRegression.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.RootNamespace = LogisticRegression 3 | build_property.ProjectDir = D:\SciSharp\出版相关\《TensorFlow.NET实战》代码案例资源\第6章 MNIST 手写字符分类逻辑回归\LogisticRegression\LogisticRegression\ 4 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/obj/Debug/netcoreapp3.1/LogisticRegression.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/obj/Debug/netcoreapp3.1/LogisticRegression.assets.cache -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/obj/Debug/netcoreapp3.1/LogisticRegression.csproj.AssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SciSharp/tensorflow-net-docs/643f916df3fa3318177648c65e4b2e27ca2e9f2a/Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/obj/Debug/netcoreapp3.1/LogisticRegression.csproj.AssemblyReference.cache -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/obj/LogisticRegression.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 | 6.3.0 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/obj/LogisticRegression.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/LogisticRegression/LogisticRegression/obj/project.nuget.cache: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "dgSpecHash": "EOBvXRZSiGhBy+HogbPzOdRulAh1u7ZQKJX4mRbzOvVTyJFWhhsU2WcR+oBAO3YCKWVk2ACm0WJJMBccKiYSDw==", 4 | "success": true, 5 | "projectFilePath": "D:\\SciSharp\\出版相关\\《TensorFlow.NET实战》代码案例资源\\第6章 MNIST 手写字符分类逻辑回归\\LogisticRegression\\LogisticRegression\\LogisticRegression.csproj", 6 | "expectedPackageFiles": [ 7 | "C:\\Users\\Administrator\\.nuget\\packages\\google.protobuf\\3.11.4\\google.protobuf.3.11.4.nupkg.sha512", 8 | "C:\\Users\\Administrator\\.nuget\\packages\\numsharp.lite\\0.1.7\\numsharp.lite.0.1.7.nupkg.sha512", 9 | "C:\\Users\\Administrator\\.nuget\\packages\\protobuf.text\\0.4.0\\protobuf.text.0.4.0.nupkg.sha512", 10 | "C:\\Users\\Administrator\\.nuget\\packages\\scisharp.tensorflow.redist\\2.3.0\\scisharp.tensorflow.redist.2.3.0.nupkg.sha512", 11 | "C:\\Users\\Administrator\\.nuget\\packages\\system.memory\\4.5.3\\system.memory.4.5.3.nupkg.sha512", 12 | "C:\\Users\\Administrator\\.nuget\\packages\\tensorflow.net\\0.20.0-preview3\\tensorflow.net.0.20.0-preview3.nupkg.sha512", 13 | "C:\\Users\\Administrator\\.nuget\\packages\\microsoft.netcore.app.host.win-x64\\3.1.29\\microsoft.netcore.app.host.win-x64.3.1.29.nupkg.sha512" 14 | ], 15 | "logs": [] 16 | } -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/MnistCNNKerasFunctional/MnistCNNKerasFunctional.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31005.135 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MnistCNNKerasFunctional", "MnistCNNKerasFunctional\MnistCNNKerasFunctional.csproj", "{687CB6C7-1E29-49A6-B58A-1A5CD2D35CBC}" 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 | {687CB6C7-1E29-49A6-B58A-1A5CD2D35CBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {687CB6C7-1E29-49A6-B58A-1A5CD2D35CBC}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {687CB6C7-1E29-49A6-B58A-1A5CD2D35CBC}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {687CB6C7-1E29-49A6-B58A-1A5CD2D35CBC}.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 = {81972755-660A-4BC6-A9A3-6CFCA7CF3C2F} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/MnistCNNKerasFunctional/MnistCNNKerasFunctional/MnistCNNKerasFunctional.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/MnistCNNKerasFunctional/MnistCNNKerasFunctional/Program.cs: -------------------------------------------------------------------------------- 1 | using NumSharp; 2 | using Tensorflow.Keras.Engine; 3 | using Tensorflow.Keras.Layers; 4 | using static Tensorflow.KerasApi; 5 | 6 | namespace MnistCNNKerasFunctional 7 | { 8 | class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | MnistCNN cnn = new MnistCNN(); 13 | cnn.Main(); 14 | } 15 | 16 | class MnistCNN 17 | { 18 | Model model; 19 | LayersApi layers = new LayersApi(); 20 | NDArray x_train, y_train, x_test, y_test; 21 | public void Main() 22 | { 23 | // Step-1. Prepare Data 24 | (x_train, y_train, x_test, y_test) = keras.datasets.mnist.load_data(); 25 | x_train = x_train.reshape(60000, 28, 28, 1) / 255f; 26 | x_test = x_test.reshape(10000, 28, 28, 1) / 255f; 27 | 28 | // Step-2. Build CNN Model with Keras Functional 29 | // input layer 30 | var inputs = keras.Input(shape: (28, 28, 1)); 31 | // 1st convolution layer 32 | var outputs = layers.Conv2D(32, kernel_size: 5, activation: keras.activations.Relu).Apply(inputs); 33 | // 2nd maxpooling layer 34 | outputs = layers.MaxPooling2D(2, strides: 2).Apply(outputs); 35 | // 3nd convolution layer 36 | outputs = layers.Conv2D(64, kernel_size: 3, activation: keras.activations.Relu).Apply(outputs); 37 | // 4nd maxpooling layer 38 | outputs = layers.MaxPooling2D(2, strides: 2).Apply(outputs); 39 | // 5nd flatten layer 40 | outputs = layers.Flatten().Apply(outputs); 41 | // 6nd dense layer 42 | outputs = layers.Dense(1024).Apply(outputs); 43 | // 7nd dropout layer 44 | outputs = layers.Dropout(rate: 0.5f).Apply(outputs); 45 | // output layer 46 | outputs = layers.Dense(10).Apply(outputs); 47 | // build keras model 48 | model = keras.Model(inputs, outputs, name: "mnist_model"); 49 | // show model summary 50 | model.summary(); 51 | // compile keras model into tensorflow's static graph 52 | model.compile(loss: keras.losses.SparseCategoricalCrossentropy(from_logits: true), 53 | optimizer: keras.optimizers.Adam(learning_rate: 0.001f), 54 | metrics: new[] { "accuracy" }); 55 | 56 | // Step-3. Train Model 57 | // train model by feeding data and labels. 58 | model.fit(x_train, y_train, batch_size: 64, epochs: 2, validation_split: 0.2f); 59 | // evluate the model 60 | model.evaluate(x_test, y_test, verbose: 2); 61 | 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/MnistCNNKerasFunctional/MnistCNNKerasFunctional/obj/MnistCNNKerasFunctional.csproj.nuget.dgspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "format": 1, 3 | "restore": { 4 | "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional.csproj": {} 5 | }, 6 | "projects": { 7 | "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional.csproj": { 8 | "version": "1.0.0", 9 | "restore": { 10 | "projectUniqueName": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional.csproj", 11 | "projectName": "MnistCNNKerasFunctional", 12 | "projectPath": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional.csproj", 13 | "packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\", 14 | "outputPath": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional\\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 | "imports": [ 51 | "net461", 52 | "net462", 53 | "net47", 54 | "net471", 55 | "net472", 56 | "net48" 57 | ], 58 | "assetTargetFallback": true, 59 | "warn": true, 60 | "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.201\\RuntimeIdentifierGraph.json" 61 | } 62 | } 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/MnistCNNKerasFunctional/MnistCNNKerasFunctional/obj/MnistCNNKerasFunctional.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 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/MnistCNNKerasFunctional/MnistCNNKerasFunctional/obj/MnistCNNKerasFunctional.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/MnistCNNKerasFunctional/MnistCNNKerasFunctional/obj/project.assets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "targets": { 4 | "net5.0": {} 5 | }, 6 | "libraries": {}, 7 | "projectFileDependencyGroups": { 8 | "net5.0": [] 9 | }, 10 | "packageFolders": { 11 | "C:\\Users\\Administrator\\.nuget\\packages\\": {}, 12 | "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}, 13 | "C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\": {}, 14 | "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {} 15 | }, 16 | "project": { 17 | "version": "1.0.0", 18 | "restore": { 19 | "projectUniqueName": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional.csproj", 20 | "projectName": "MnistCNNKerasFunctional", 21 | "projectPath": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional.csproj", 22 | "packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\", 23 | "outputPath": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional\\obj\\", 24 | "projectStyle": "PackageReference", 25 | "fallbackFolders": [ 26 | "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages", 27 | "C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\", 28 | "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder" 29 | ], 30 | "configFilePaths": [ 31 | "C:\\Users\\Administrator\\AppData\\Roaming\\NuGet\\NuGet.Config", 32 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config", 33 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config", 34 | "C:\\Program Files (x86)\\NuGet\\Config\\Xamarin.Offline.config" 35 | ], 36 | "originalTargetFrameworks": [ 37 | "net5.0" 38 | ], 39 | "sources": { 40 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, 41 | "C:\\Users\\Administrator\\Desktop": {}, 42 | "https://api.nuget.org/v3/index.json": {} 43 | }, 44 | "frameworks": { 45 | "net5.0": { 46 | "targetAlias": "net5.0", 47 | "projectReferences": {} 48 | } 49 | }, 50 | "warningProperties": { 51 | "warnAsError": [ 52 | "NU1605" 53 | ] 54 | } 55 | }, 56 | "frameworks": { 57 | "net5.0": { 58 | "targetAlias": "net5.0", 59 | "imports": [ 60 | "net461", 61 | "net462", 62 | "net47", 63 | "net471", 64 | "net472", 65 | "net48" 66 | ], 67 | "assetTargetFallback": true, 68 | "warn": true, 69 | "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.201\\RuntimeIdentifierGraph.json" 70 | } 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/MnistCNNKerasFunctional/MnistCNNKerasFunctional/obj/project.nuget.cache: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "dgSpecHash": "jJi8qQn6I7iUqGSjkLOgctzFfpU110VHpOg2C+sWLKLUAXicfXfErun1iCEfAlKj+CgO3DCMFq+KVtdiuIDu9Q==", 4 | "success": true, 5 | "projectFilePath": "C:\\Users\\Administrator\\Desktop\\TensorFlow.NET-Tutorials\\PracticeCode\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional\\MnistCNNKerasFunctional.csproj", 6 | "expectedPackageFiles": [], 7 | "logs": [] 8 | } -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/TensorDebuggerVisualizersTest/TensorDebuggerVisualizersTest.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31410.357 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensorDebuggerVisualizersTest", "TensorDebuggerVisualizersTest\TensorDebuggerVisualizersTest.csproj", "{6B46C67F-BD01-42FD-8C4C-7CCA4BC8BE59}" 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 | {6B46C67F-BD01-42FD-8C4C-7CCA4BC8BE59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {6B46C67F-BD01-42FD-8C4C-7CCA4BC8BE59}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {6B46C67F-BD01-42FD-8C4C-7CCA4BC8BE59}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {6B46C67F-BD01-42FD-8C4C-7CCA4BC8BE59}.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 = {14E8EABA-CEFF-41E7-9AB8-15FBEBA56770} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/TensorDebuggerVisualizersTest/TensorDebuggerVisualizersTest/Program.cs: -------------------------------------------------------------------------------- 1 | using static SharpCV.Binding; 2 | 3 | namespace TensorDebuggerVisualizersTest 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | var img = cv2.imread("img.bmp"); 10 | var img_rotate = cv2.rotate(img, SharpCV.RotateFlags.ROTATE_90_CLOCKWISE); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/TensorDebuggerVisualizersTest/TensorDebuggerVisualizersTest/TensorDebuggerVisualizersTest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/TensorDebuggerVisualizersTest/TensorDebuggerVisualizersTest/obj/TensorDebuggerVisualizersTest.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 | 25 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/TensorDebuggerVisualizersTest/TensorDebuggerVisualizersTest/obj/TensorDebuggerVisualizersTest.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/TransferLearningWithInceptionV3/TransferLearningWithInceptionV3.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31321.278 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransferLearningWithInceptionV3", "TransferLearningWithInceptionV3\TransferLearningWithInceptionV3.csproj", "{3C9EB905-0BC2-4315-9CE4-9B9E2AD09A86}" 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 | {3C9EB905-0BC2-4315-9CE4-9B9E2AD09A86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3C9EB905-0BC2-4315-9CE4-9B9E2AD09A86}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3C9EB905-0BC2-4315-9CE4-9B9E2AD09A86}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3C9EB905-0BC2-4315-9CE4-9B9E2AD09A86}.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 = {DB998308-4697-4196-8B74-8A4CEF2A2737} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/TransferLearningWithInceptionV3/TransferLearningWithInceptionV3/TransferLearningWithInceptionV3.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/TransferLearningWithInceptionV3/TransferLearningWithInceptionV3/obj/TransferLearningWithInceptionV3.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 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/TransferLearningWithInceptionV3/TransferLearningWithInceptionV3/obj/TransferLearningWithInceptionV3.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/YOLOv3_Test/YOLOv3_Test.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}") = "YOLOv3_Test", "YOLOv3_Test\YOLOv3_Test.csproj", "{928EFDAA-E803-4CD6-ADAD-8749B30B9965}" 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 | {928EFDAA-E803-4CD6-ADAD-8749B30B9965}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {928EFDAA-E803-4CD6-ADAD-8749B30B9965}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {928EFDAA-E803-4CD6-ADAD-8749B30B9965}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {928EFDAA-E803-4CD6-ADAD-8749B30B9965}.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 = {915A4FAB-BC2D-4F69-907C-8C8B22E265F9} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/YOLOv3_Test/YOLOv3_Test/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace YOLOv3_Test 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | //var test = new TestImage(); 10 | var test = new TestVideo(); 11 | test.Run(); 12 | 13 | Console.WriteLine("YOLOv3 Test is completed."); 14 | Console.ReadLine(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/YOLOv3_Test/YOLOv3_Test/TestImage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NumSharp; 3 | using SharpCV; 4 | using Tensorflow; 5 | using static SharpCV.Binding; 6 | using static YOLOv3_Test.YOLOv3; 7 | 8 | namespace YOLOv3_Test 9 | { 10 | class TestImage 11 | { 12 | public bool Run() 13 | { 14 | PredictFromImage(); 15 | return true; 16 | } 17 | private void PredictFromImage() 18 | { 19 | var graph = ImportGraph(); 20 | using (var sess = new Session(graph)) 21 | { 22 | var original_image_raw = cv2.imread(AppDomain.CurrentDomain.BaseDirectory + @"yolov3\cat_face.jpg"); 23 | var original_image = cv2.cvtColor(original_image_raw, ColorConversionCodes.COLOR_BGR2RGB); 24 | var original_image_size = (original_image.shape[0], original_image.shape[1]); 25 | var image_data = image_preporcess(original_image, (input_size, input_size)); 26 | image_data = image_data[np.newaxis, Slice.Ellipsis]; 27 | 28 | var (pred_sbbox, pred_mbbox, pred_lbbox) = sess.run((return_tensors[1], return_tensors[2], return_tensors[3]), 29 | (return_tensors[0], image_data)); 30 | 31 | var pred_bbox = np.concatenate((np.reshape(pred_sbbox, (-1, 5 + num_classes)), 32 | np.reshape(pred_mbbox, (-1, 5 + num_classes)), 33 | np.reshape(pred_lbbox, (-1, 5 + num_classes))), axis: 0); 34 | 35 | var bboxes = postprocess_boxes(pred_bbox, original_image_size, input_size, 0.03f);//as is: 0.3f 36 | var bboxess = nms(bboxes, 0.3f, method: "nms");//as is: 0.5f 37 | var image = draw_bbox(original_image_raw, bboxess); 38 | cv2.imshow("Detected Objects in TensorFlow.NET", image); 39 | cv2.waitKey(); 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/YOLOv3_Test/YOLOv3_Test/TestVideo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NumSharp; 3 | using Tensorflow; 4 | using static SharpCV.Binding; 5 | using static YOLOv3_Test.YOLOv3; 6 | 7 | namespace YOLOv3_Test 8 | { 9 | class TestVideo 10 | { 11 | public bool Run() 12 | { 13 | PredictFromVideo(); 14 | return true; 15 | } 16 | private void PredictFromVideo() 17 | { 18 | var graph = ImportGraph(); 19 | using (var sess = new Session(graph)) 20 | { 21 | // Opens MP4 file (ffmpeg is probably needed) 22 | var vid = cv2.VideoCapture(AppDomain.CurrentDomain.BaseDirectory + @"yolov3\road.mp4"); 23 | int sleepTime = (int)Math.Round(1000 / 24.0); 24 | var (loaded, frame) = vid.read(); 25 | while (loaded) 26 | { 27 | var frame_size = (frame.shape[0], frame.shape[1]); 28 | var image_data = image_preporcess(frame, (input_size, input_size)); 29 | image_data = image_data[np.newaxis, Slice.Ellipsis]; 30 | 31 | var (pred_sbbox, pred_mbbox, pred_lbbox) = sess.run((return_tensors[1], return_tensors[2], return_tensors[3]), 32 | (return_tensors[0], image_data)); 33 | 34 | var pred_bbox = np.concatenate((np.reshape(pred_sbbox, (-1, 5 + num_classes)), 35 | np.reshape(pred_mbbox, (-1, 5 + num_classes)), 36 | np.reshape(pred_lbbox, (-1, 5 + num_classes))), axis: 0); 37 | 38 | var bboxes = postprocess_boxes(pred_bbox, frame_size, input_size, 0.3f); 39 | var bboxess = nms(bboxes, 0.45f, method: "nms"); 40 | var image = draw_bbox(frame, bboxess); 41 | 42 | cv2.imshow("objects", image); 43 | cv2.waitKey(sleepTime); 44 | 45 | (loaded, frame) = vid.read(); 46 | } 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/YOLOv3_Test/YOLOv3_Test/YOLOv3_Test.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 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/YOLOv3_Test/YOLOv3_Test/obj/YOLOv3_Test.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 | 25 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/YOLOv3_Test/YOLOv3_Test/obj/YOLOv3_Test.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/YoloV3_train/YoloV3_train.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}") = "YoloV3_train", "YoloV3_train\YoloV3_train.csproj", "{35833CFE-FC76-4B03-85E0-5EA9A68E90F1}" 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 | {35833CFE-FC76-4B03-85E0-5EA9A68E90F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {35833CFE-FC76-4B03-85E0-5EA9A68E90F1}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {35833CFE-FC76-4B03-85E0-5EA9A68E90F1}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {35833CFE-FC76-4B03-85E0-5EA9A68E90F1}.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 = {172948AE-96AA-43A8-8242-2416F6A7A514} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/YoloV3_train/YoloV3_train/Core/Backbone.cs: -------------------------------------------------------------------------------- 1 | using Tensorflow; 2 | using static Tensorflow.Binding; 3 | 4 | 5 | namespace YoloV3_train.Core 6 | { 7 | class Backbone 8 | { 9 | 10 | public static (Tensor, Tensor, Tensor) darknet53(Tensor input_data) 11 | { 12 | input_data = Common.convolutional(input_data, (3, 3, 3, 32)); 13 | input_data = Common.convolutional(input_data, (3, 3, 32, 64), downsample: true); 14 | foreach (var i in range(1)) 15 | input_data = Common.residual_block(input_data, 64, 32, 64); 16 | 17 | input_data = Common.convolutional(input_data, filters_shape: (3, 3, 64, 128), downsample: true); 18 | foreach (var i in range(2)) 19 | input_data = Common.residual_block(input_data, 128, 64, 128); 20 | 21 | input_data = Common.convolutional(input_data, filters_shape: (3, 3, 128, 256), downsample: true); 22 | 23 | foreach (var i in range(8)) 24 | input_data = Common.residual_block(input_data, 256, 128, 256); 25 | 26 | var route_1 = input_data; 27 | input_data = Common.convolutional(input_data, filters_shape: (3, 3, 256, 512), downsample: true); 28 | 29 | foreach (var i in range(8)) 30 | input_data = Common.residual_block(input_data, 512, 256, 512); 31 | 32 | var route_2 = input_data; 33 | input_data = Common.convolutional(input_data, filters_shape: (3, 3, 512, 1024), downsample: true); 34 | 35 | foreach (var i in range(4)) 36 | input_data = Common.residual_block(input_data, 1024, 512, 1024); 37 | 38 | return (route_1, route_2, input_data); 39 | } 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Code in TensorFlow.NET Practice/YoloV3_train/YoloV3_train/Core/BatchFeedingImage.cs: -------------------------------------------------------------------------------- 1 | using NumSharp; 2 | using System.Collections.Generic; 3 | 4 | namespace YoloV3_train.Core 5 | { 6 | class BatchFeedingImage 7 | { 8 | public NDArray Image { get; set; } 9 | public List 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 | ![logo](_images/tf.net.logo.png ":no-zoom") 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 | ![Front Cover](../_images/front-cover.jpg) 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 | ![image](../_media/graph_vis_animation.gif) 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 ![1557035393445](../_images\logistic-regression\1557035393445.png) 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 | ![](../_images/tensor-naming.png) 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 | ![column-major order](../_images/column-major-order.png) 45 | 46 | ![row-major order](../_images/row-major-order.png) 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 | ![SciSharp STACK](../_media/TIM.jpg) 10 | 11 | WeChat Sponsor 微信打赏: 12 | 13 | ![SciSharp STACK](../_media/WeChatCollection.jpg) 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 | ![New Project](../_images/new-project.png) 20 | 21 | 2. Choose Console App (.NET Core) 22 | 23 | ![Console App](../_images/new-project-console.png) 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 | ![](../_images/Automatic-Differentiation.png) 27 | -------------------------------------------------------------------------------- /docs/zh-cn/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ![logo](../_images/tf.net.logo.png ":no-zoom") 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 | ![SciSharp STACK](../../_media/TIM.jpg) 10 | 11 | 微信打赏谢谢了老铁们: 12 | 13 | ![SciSharp STACK](../../_media/WeChatCollection.jpg) 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 | ![](../../_images/Automatic-Differentiation.png) 27 | --------------------------------------------------------------------------------