NumSharp 0.20.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NumSharp --version 0.20.0
NuGet\Install-Package NumSharp -Version 0.20.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="NumSharp" Version="0.20.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NumSharp --version 0.20.0
#r "nuget: NumSharp, 0.20.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.
// Install NumSharp as a Cake Addin
#addin nuget:?package=NumSharp&version=0.20.0

// Install NumSharp as a Cake Tool
#tool nuget:?package=NumSharp&version=0.20.0


NumPy port in C# .NET Standard<a href=""><img src="" width="200" height="200" align="right" /></a>

Join the chat at AppVeyor codecov NuGet Badge

Is it difficult to translate python machine learning code into C#? Because too many functions can’t be found in the corresponding code in the .Net SDK. NumSharp is the C# version of NumPy, which is as consistent as possible with the NumPy programming interface, including function names and parameter locations. By introducing the NumSharp tool library, you can easily convert from python code to C# code. Here is a comparison code between NumSharp and NumPy (left is python, right is C#):


If you want to read some more informations, we start a doc on

NumSharp has implemented the arange, array, max, min, reshape, normalize, unique interfaces. More and more interfaces will be added to the library gradually. If you want to use .NET to get started with machine learning, NumSharp will be your best tool library.

Implemented APIs

The NumPy class is a high-level abstraction of NDArray that allows NumSharp to be used in the same way as Python's NumPy, minimizing API differences caused by programming language features, allowing .NET developers to maximize Utilize a wide range of NumPy code resources to seamlessly translate python code into .NET code.

Check the code: src\NumSharp.Core\APIs

How to use

using NumSharp;
// create a vector
var nd = np.arange(12)

// create a matrix
nd = np.arange(12).reshape(3, 4);

// access data by index
var data = nd[1, 1];

// create a tensor
nd = np.arange(12).reshape(2, 3, 2);

// get the 2nd vector in the 1st dimension
data = n[new Shape(1)];

// get the 3rd vector in the (axis 1, axis 2) dimension
data = n[new Shape(1, 2)];

// interate ndarray
foreach (data in nd)
  // data is a ndarray or a value

Install NumSharp in NuGet

PM> Install-Package NumSharp

How to make docs

How to run benchmark

C: \> dotnet NumSharp.Benchmark.dll nparange

Reference the documents generated by DocFX.

Reference the documents host on

NumSharp is referenced by:

You might also be interested in NumSharp's sister project Numpy.NET.

NumSharp is a member project of which is the .NET based ecosystem of open-source software for mathematics, science, and engineering. Welcome to fork and pull request to add more APIs, and make reference list longer.

<img src="" width="80">

Join us on Gitter

Scan QR code to join TIM group:

SciSharp STACK

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. 
.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 net461 was computed.  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)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (17)

Showing the top 5 NuGet packages that depend on NumSharp:

Package Downloads
Microsoft.Quantum.Simulators The ID prefix of this package has been reserved for one of the owners of this package by

Classical simulators of quantum computers for the Q# programming language.

Microsoft.Quantum.Standard The ID prefix of this package has been reserved for one of the owners of this package by

Microsoft's Quantum standard libraries.


Machine Learning library in .NET Core.

Microsoft.Quantum.Standard.Visualization The ID prefix of this package has been reserved for one of the owners of this package by

Provides IQ# visualization support for Microsoft's Q# standard libraries.

Package Description

GitHub repositories (9)

Showing the top 5 popular GitHub repositories that depend on NumSharp:

Repository Stars
Open singing synthesis platform / Open source UTAU successor
High Performance Computation for N-D Tensors in .NET, similar API to NumPy.
Open deep learning compiler stack for Kendryte AI accelerator ✨
An easy to use C# deep learning library with CUDA/OpenCL support
Runtime components for Q#
Version Downloads Last updated
0.30.0 236,891 2/14/2021
0.20.5 674,690 12/31/2019
0.20.4 317,080 10/5/2019
0.20.3 3,084 9/28/2019
0.20.2 2,118 9/11/2019
0.20.1 17,126 9/1/2019
0.20.0 3,279 8/20/2019
0.10.6 25,451 7/24/2019
0.10.5 2,042 7/22/2019
0.10.4 2,046 7/18/2019
0.10.3 10,662 6/15/2019
0.10.2 1,841 5/25/2019
0.10.1 3,272 5/11/2019
0.10.0 2,027 5/5/2019
0.9.0 2,933 4/15/2019
0.8.3 1,682 3/29/2019
0.8.2 2,325 3/25/2019
0.8.1 1,810 3/22/2019
0.8.0 1,980 3/12/2019
0.7.4 1,545 3/7/2019
0.7.3 485,373 2/20/2019
0.7.2 1,924 2/18/2019
0.7.1 1,963 2/12/2019
0.7.0 1,613 1/28/2019
0.6.6 1,929 1/26/2019
0.6.5 1,984 1/11/2019
0.6.4 1,988 1/7/2019
0.6.3 1,592 12/30/2018
0.6.2 4,798 12/27/2018
0.6.1 1,540 12/26/2018
0.6.0 1,621 12/21/2018
0.5.0 1,651 12/5/2018
0.4.0 1,531 11/21/2018
0.3.0 1,564 11/7/2018
0.2.0 3,280 10/29/2018
0.1.0 1,760 10/10/2018

Most of the library (>95%) has been rewritten within over 400 commits in course of 3 months.

- Full n-d, slice, broadcasting and axis support in all reimplemented methods (e.g. np.sum, np.concatenate) Broadcasting n-d shapes against each other.

- NDArray Slicing and nested slicing (nd["-1, ::2"]["1::3, :, 0"])

- Full and precise (to numpy) type resolving and conversion (upcasting, downcasting and all other cases)

- Use of unmanaged memory and unsafe code in favor of performance.

- NumSharp no longer perform copies except for cases when numpy does. Compared to previous version, indexing an n-d array (e.g. nd[0,1] when shape is (3,3,3,3)) would return a copy when now it returns a reference (alias).