TensorFlowSharp 1.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package TensorFlowSharp --version 1.5.0 
NuGet\Install-Package TensorFlowSharp -Version 1.5.0 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TensorFlowSharp" Version="1.5.0" /> 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TensorFlowSharp" Version="1.5.0" /> 
Directory.Packages.props
<PackageReference Include="TensorFlowSharp" /> 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TensorFlowSharp --version 1.5.0 
#r "nuget: TensorFlowSharp, 1.5.0" 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TensorFlowSharp@1.5.0 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TensorFlowSharp&version=1.5.0 
Install as a Cake Addin
#tool nuget:?package=TensorFlowSharp&version=1.5.0 
Install as a Cake Tool

Your best source of information right now are the SampleTest that exercises various APIs of TensorFlowSharp, or the stand-alone samples located in "Examples".

You can also access the API documentation.

This API binding is closer design-wise to the Java and Go bindings which use explicit TensorFlow graphs and sessions. Your application will typically create a graph (TFGraph) and setup the operations there, then create a session from it (TFSession), then use the session runner to setup inputs and outputs and execute the pipeline.

Something like this:

using(var graph = new TFGraph ()) { graph.Import (File.ReadAllBytes ("MySavedModel")); var session = new TFSession (graph); var runner = session.GetRunner (); runner.AddInput (graph ["input"] [0], tensor); runner.Fetch (graph ["output"] [0]); var output = runner.Run (); // Fetch the results from output: TFTensor result = output [0]; } 

In scenarios where you do not need to setup the graph independently, the session will create one for you. The following example shows how to abuse TensorFlow to compute the addition of two numbers:

using (var session = new TFSession()) { var graph = session.Graph; var a = graph.Const(2); var b = graph.Const(3); Console.WriteLine("a=2 b=3"); // Add two constants var addingResults = session.GetRunner().Run(graph.Add(a, b)); var addingResultValue = addingResults.GetValue(); Console.WriteLine("a+b={0}", addingResultValue); // Multiply two constants var multiplyResults = session.GetRunner().Run(graph.Mul(a, b)); var multiplyResultValue = multiplyResults.GetValue(); Console.WriteLine("a*b={0}", multiplyResultValue); } 

Here is an F# scripting version of the same example, you can use this in F# Interactive:

#r @"packages\TensorFlowSharp.1.5.0\lib\net461\TensorFlowSharp.dll" open System open System.IO open TensorFlow // set the path to find the native DLL Environment.SetEnvironmentVariable("Path", Environment.GetEnvironmentVariable("Path") + ";" + __SOURCE_DIRECTORY__ + @"/packages/TensorFlowSharp.1.2.2/native") module AddTwoNumbers = let session = new TFSession() let graph = session.Graph let a = graph.Const(new TFTensor(2)) let b = graph.Const(new TFTensor(3)) Console.WriteLine("a=2 b=3") // Add two constants let addingResults = session.GetRunner().Run(graph.Add(a, b)) let addingResultValue = addingResults.GetValue() Console.WriteLine("a+b={0}", addingResultValue) // Multiply two constants let multiplyResults = session.GetRunner().Run(graph.Mul(a, b)) let multiplyResultValue = multiplyResults.GetValue() Console.WriteLine("a*b={0}", multiplyResultValue) 
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on TensorFlowSharp:

Package Downloads
DeepMorphy

Morphological analyzer for Russian language

SiaNet.Backend.TensorFlowLib

TensorFlow backend for SiaNet library. Please install SiaNet along with this backend.

Neuromatic

Package Description

Crosser.EdgeNode.Modules.TensorFlow

Package Description

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on TensorFlowSharp:

Repository Stars
cesarsouza/keras-sharp
Keras# initiated as an effort to port the Keras deep learning library to C#, supporting both TensorFlow and CNTK
Azure/sg-aks-workshop
Security + Governance Workshop
Version Downloads Last Updated
1.15.1 259,398 12/4/2019
1.15.0 5,894 11/25/2019
1.15.0-pre2 1,333 11/7/2019
1.15.0-pre1 1,308 11/5/2019
1.13.1 93,285 11/4/2019
1.13.0 170,762 5/1/2019
1.12.0 63,141 12/6/2018
1.11.0 15,986 10/2/2018
1.10.0 6,860 9/7/2018
1.9.0 7,490 8/7/2018
1.9.0-pre1 2,088 8/2/2018
1.8.0-pre1 8,229 5/25/2018
1.7.0 39,652 4/15/2018
1.7.0-pre1 1,974 4/3/2018
1.6.0-pre1 2,257 3/11/2018
1.5.1-pre1 1,717 3/1/2018
1.5.0 13,636 1/27/2018
1.5.0-pre2 1,661 1/24/2018
1.5.0-pre1 1,863 1/14/2018
1.4.0 12,848 11/22/2017
1.4.0-pre1 2,185 11/5/2017
1.3.1-pre1 1,685 9/15/2017
1.3.0 4,279 9/15/2017
1.3.0-pre1 2,480 8/26/2017
1.2.2 13,213 6/28/2017
1.2.1 1,891 6/28/2017
0.96.0 9,766 5/21/2017
0.95.0 1,889 5/21/2017
0.94.0 1,798 5/21/2017
0.13.1 1,189 11/4/2019
0.13.0 2,826 5/1/2019

Adds support for TensorFlow 1.5

* No longer a -pre release
* Ships the latest official 1.5 packages (January 26th, Build #80 Mac, Linux, #59 Windows)
* This brings support for the TensorFlow 1.5 API
* New transpose overload without explicit perm parameter (Cesar Souza)
* New ReduceProd method (Cesar Souza)
* Supports for TensorFlow.Cond (Cesar Souza)
* Ships the latest official 1.5 packages.