{"id":13534991,"url":"https://github.com/SciSharp/NumSharp","last_synced_at":"2025-04-02T00:31:23.723Z","repository":{"id":42109798,"uuid":"152337800","full_name":"SciSharp/NumSharp","owner":"SciSharp","description":"High Performance Computation for N-D Tensors in .NET, similar API to NumPy.","archived":false,"fork":false,"pushed_at":"2023-12-17T19:16:51.000Z","size":33935,"stargazers_count":1420,"open_issues_count":143,"forks_count":197,"subscribers_count":74,"default_branch":"master","last_synced_at":"2025-03-31T22:18:19.063Z","etag":null,"topics":["machine-learning","numpy","numsharp","pandas"],"latest_commit_sha":null,"homepage":"https://github.com/SciSharp","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SciSharp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://bit.ly/2op1mu5"]}},"created_at":"2018-10-10T00:10:09.000Z","updated_at":"2025-03-31T05:01:42.000Z","dependencies_parsed_at":"2023-12-17T19:46:13.393Z","dependency_job_id":null,"html_url":"https://github.com/SciSharp/NumSharp","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SciSharp%2FNumSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SciSharp%2FNumSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SciSharp%2FNumSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SciSharp%2FNumSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SciSharp","download_url":"https://codeload.github.com/SciSharp/NumSharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246735066,"owners_count":20825212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["machine-learning","numpy","numsharp","pandas"],"created_at":"2024-08-01T08:00:48.133Z","updated_at":"2025-04-02T00:31:23.712Z","avatar_url":"https://github.com/SciSharp.png","language":"C#","readme":"[![NumSharp](docs/images/numsharp.logo.png)](docs/images/numsharp.logo.png)\n\n[![NuGet](https://img.shields.io/nuget/dt/NumSharp.svg)](https://www.nuget.org/packages/NumSharp)\n[![Join the chat at https://gitter.im/publiclab/publiclab](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sci-sharp/community)\n[![AppVeyor](https://ci.appveyor.com/api/projects/status/bmaauxd9rx5lsq9i?svg=true)](https://ci.appveyor.com/project/Haiping-Chen/numsharp)\n[![codecov](https://codecov.io/gh/SciSharp/NumSharp/branch/master/graph/badge.svg)](https://codecov.io/gh/SciSharp/NumSharp)\n[![Badge](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu/#/en_US)\n\n**NumSharp** (NS) is a [NumPy](https://github.com/numpy/numpy) port to C# targetting .NET Standard.\u003ca href=\"http://scisharpstack.org\"\u003e\u003cimg src=\"https://github.com/SciSharp/SciSharp/blob/master/art/scisharp_badge.png\" width=\"200\" height=\"200\" align=\"right\" /\u003e\u003c/a\u003e\u003cbr\u003e\nNumSharp is the fundamental package needed for scientific computing with C# and F#.\u003cbr\u003e\n\nIs it difficult to translate python machine learning code into .NET? Because too many functions can’t be found in the corresponding code in the .NET SDK. \nNumSharp 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# or F# code.\nHere is a comparison code between NumSharp and NumPy (left is python, right is C#):\n\n[![comparision](docfx_project/images/python-csharp-comparision.png)](https://raw.githubusercontent.com/SciSharp/NumSharp/master/docfx_project/images/python-csharp-comparision.png)\n\n### Bold Features\n* Use of Unmanaged Memory and fast unsafe algorithms.\n* [Broadcasting](https://docs.scipy.org/doc/numpy-1.15.0/user/basics.broadcasting.html) n-d shapes against each other. ([intro](https://machinelearningmastery.com/broadcasting-with-numpy-arrays/))\n* [NDArray Slicing](https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html) and nested/recusive slicing (`nd[\"-1, ::2\"][\"1::3, :, 0\"]`)\n* Axis iteration and support in all of our implemented functions.\n* Full and precise (to numpy) automatic type resolving and conversion (upcasting, downcasting and other cases)\n* Non-copy - most cases, similarly to numpy, does not perform copying but returns a view instead.\n* Almost non-effort copy-pasting numpy code from python to C#.\n* Wide support for `System.Drawing.Bitmap`. ([read more](https://github.com/SciSharp/NumSharp/wiki/Bitmap-Extensions))\n\n### Implemented APIs\nThe 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.\n\n### Install NumSharp in NuGet\n```sh\nPM\u003e Install-Package NumSharp\n```\n\n### How to use\n```cs\nusing NumSharp;\n\nvar nd = np.full(5, 12); //[5, 5, 5 .. 5]\nnd = np.zeros(12); //[0, 0, 0 .. 0]\nnd = np.arange(12); //[0, 1, 2 .. 11]\n\n// create a matrix\nnd = np.zeros((3, 4)); //[0, 0, 0 .. 0]\nnd = np.arange(12).reshape(3, 4);\n\n// access data by index\nvar data = nd[1, 1];\n\n// create a tensor\nnd = np.arange(12);\n\n// reshaping\ndata = nd.reshape(2, -1); //returning ndarray shaped (2, 6)\n\nShape shape = (2, 3, 2);\ndata = nd.reshape(shape); //Tuple implicitly casted to Shape\n    //or:\nnd =   nd.reshape(2, 3, 2);\n\n// slicing tensor\ndata = nd[\":, 0, :\"]; //returning ndarray shaped (2, 1, 2)\ndata = nd[Slice.All, 0, Slice.All]; //equivalent to the line above.\n\n// nd is currently shaped (2, 3, 2)\n// get the 2nd vector in the 1st dimension\ndata = nd[1]; //returning ndarray shaped (3, 2)\n\n// get the 3rd vector in the (axis 1, axis 2) dimension\ndata = nd[1, 2]; //returning ndarray shaped (2, )\n\n// get flat representation of nd\ndata = nd.flat; //or nd.flatten() for a copy\n\n// interate ndarray\nforeach (object val in nd)\n{\n    // val can be either boxed value-type or a NDArray.\n}\n\nvar iter = nd.AsIterator\u003cint\u003e(); //a different T can be used to automatically perform cast behind the scenes.\nwhile (iter.HasNext())\n{\n    //read\n    int val = iter.MoveNext();\n\n    //write\n    iter.MoveNextReference() = 123; //set value to the next val\n    //note that setting is not supported when calling AsIterator\u003cT\u003e() where T is not the dtype of the ndarray.\n}\n```\n\n### How to run benchmark\n```\nC: \\\u003e dotnet NumSharp.Benchmark.dll nparange\n```\n\n### NumSharp is referenced by\n* [dotnet/ML.NET](https://github.com/dotnet/machinelearning)\n* [ScipSharp/TensorFlow.NET](https://github.com/SciSharp/TensorFlow.NET)\n* [ScipSharp/Gym.NET](https://github.com/SciSharp/Gym.NET)\n* [ScipSharp/Pandas.NET](https://github.com/SciSharp/Pandas.NET)\n* [Oceania2018/Bigtree.MachineLearning](https://github.com/Oceania2018/Bigtree.MachineLearning)\n* [Oceania2018/CherubNLP](https://github.com/Oceania2018/CherubNLP)\n* [SciSharp/BotSharp](https://github.com/SciSharp/BotSharp)\n\nYou might also be interested in NumSharp's sister project [Numpy.NET](https://github.com/SciSharp/Numpy.NET) which provides a more whole implementation of numpy by using [pythonnet](https://github.com/pythonnet/pythonnet) and [behind-the-scenes deployment of python](https://github.com/henon/Python.Included) ([read more](https://henon.wordpress.com/2019/06/05/using-python-libraries-in-net-without-a-python-installation/)).\n\nNumSharp is a member project of [SciSharp.org](https://github.com/SciSharp) which is the .NET based ecosystem of open-source software for mathematics, science, and engineering.\n\n### Regen Templating\nOur library contains over 150,000 lines of repetitive generated code, mostly for handling different data types without hurting performance.\u003cbr\u003e\nThe templates can be recognized with `#if _REGEN` blocks and are powered by [Regen Templating Engine](https://github.com/Nucs/Regen).\u003cbr\u003e\nRegen is a powerful external tool (Visual studio extension, [download here](https://github.com/Nucs/Regen/tree/master/releases)) that generates on demand based on a C#-like `regen-lang`.\n","funding_links":["https://bit.ly/2op1mu5"],"categories":["C# #","Uncategorized","C\\#","Math and Statistics"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSciSharp%2FNumSharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSciSharp%2FNumSharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSciSharp%2FNumSharp/lists"}