mxnet.sharp

.NET Standard bindings for Apache MxNet with Imperative, Symbolic and Gluon Interface for developing, training and deploying Machine Learning models in C#. https://mxnet.tech-quantum.com/

https://github.com/deepakkumar1984/mxnet.sharp

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 5 committers (20.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.8%) to scientific vocabulary

Keywords

csharp-bindings deep-learning gluon image-classification machine-learning mxnet neural-network object-detection
Last synced: 4 months ago · JSON representation ·

Repository

.NET Standard bindings for Apache MxNet with Imperative, Symbolic and Gluon Interface for developing, training and deploying Machine Learning models in C#. https://mxnet.tech-quantum.com/

Basic Info
  • Host: GitHub
  • Owner: deepakkumar1984
  • License: apache-2.0
  • Language: C#
  • Default Branch: master
  • Homepage:
  • Size: 17 MB
Statistics
  • Stars: 149
  • Watchers: 12
  • Forks: 8
  • Open Issues: 3
  • Releases: 6
Topics
csharp-bindings deep-learning gluon image-classification machine-learning mxnet neural-network object-detection
Created over 6 years ago · Last pushed over 2 years ago
Metadata Files
Readme Contributing Funding License Code of conduct Citation Codemeta

README.md

Work In Progress version 2.0.

There are many breaking change as per RFC: https://github.com/apache/incubator-mxnet/issues/16167. With this change we are introducing NumPy-compatible coding experience into MXNet

Gitter Build Status NuGet


Apache MXNet (incubating) for Deep Learning

Apache MXNet (incubating) is a deep learning framework designed for both efficiency and flexibility. It allows you to mix symbolic and imperative programming to maximize efficiency and productivity. At its core, MXNet contains a dynamic dependency scheduler that automatically parallelizes both symbolic and imperative operations on the fly. A graph optimization layer on top of that makes symbolic execution fast and memory efficient. MXNet is portable and lightweight, scaling effectively to multiple GPUs and multiple machines.

MxNet.Sharp

MxNet.Sharp is a CSharp binding coving all the Imperative, Symbolic and Gluon API's with an easy to use interface. The Gluon library in Apache MXNet provides a clear, concise, and simple API for deep learning. It makes it easy to prototype, build, and train deep learning models without sacrificing training speed.

High Level Arch

High Level Arch

A New NumPy Interface for MxNet

The MXNet community is pleased to announce a new NumPy interface for MXNet that allows developers to retain the familiar syntax of NumPy, while leveraging performance gains from accelerated computing on GPUs and asynchronous execution on CPUs and GPUs, in addition to automatic differentiation for differentiable NumPy ops through MxNet.Autograd.

The new NumPy interface from MXNet, MxNet.Numpy, is intended to be a drop-in replacement for NumPy, as such mxnet.numpy supports many familiar numpy.ndarray operations necessary for developing machine learning or deep learning models and operations are continually being added.

Work List

  • [x] Project prep work for v2
  • [x] Adding numpy ndarray array object and properties
  • [x] Implementing numpy creation function
  • [x] Implementing numpy elementwise
  • [x] Numpy basic indexing
  • [ ] Numpy advance indexing
  • [x] Nummy linear algebra functions
  • [x] Numpy manipulation functions
  • [x] Numpy search and sorting functions
  • [ ] Numpy statistical functions
  • [ ] Gluon updates with numpy ops
  • [x] Implement numpy extension functions for neural network
  • [ ] Gluon probability
  • [ ] Mxnet 2 Onnx and Onnx 2 Mxnet
  • [ ] More examples
  • [ ] Unit testing
  • [x] CI Builds

MxNet.Numpy Vs NumPy Performance

Lets consider simple test to see the performance difference. I will keep adding more scenarios and with GPU test as well.

Scenario 1

```csharp using MxNet; using MxNet.Numpy; using System;

namespace PerfTest { class Program { static void Main(string[] args) { DateTime start = DateTime.Now; var x = np.random.uniform(size: new Shape(3000, 3000)); var y = np.random.uniform(size: new Shape(3000, 3000)); var d = np.dot(x, y); npx.waitall(); Console.WriteLine(d.shape); Console.WriteLine("Duration: " + (DateTime.Now - start).TotalMilliseconds / 1000); } } } ```

```python import numpy as np import time

start_time = time.time() x = np.random.uniform(0, 1, (3000, 1000)) y = np.random.uniform(0, 1, (3000, 3000)) d = np.dot(x, y);

d = 0.5 * np.sqrt(x) + np.sin(y) * np.log(x) - np.exp(y)

print(d.shape) print("--- %s sec ---" % (time.time() - start_time)) ```

Scenario 2

```csharp using MxNet; using MxNet.Numpy; using System;

namespace PerfTest { class Program { static void Main(string[] args) { DateTime start = DateTime.Now; var x = np.random.uniform(size: new Shape(30000, 10000)); var y = np.random.uniform(size: new Shape(30000, 10000)); var d = 0.5f * np.sqrt(x) + np.sin(y) * np.log(x) - np.exp(y); npx.waitall(); Console.WriteLine(d.shape); Console.WriteLine("Duration: " + (DateTime.Now - start).TotalMilliseconds / 1000); } } } ```

```python import numpy as np import time

starttime = time.time() x = np.random.uniform(0, 1, (30000, 10000)) y = np.random.uniform(0, 1, (30000, 10000)) d = 0.5 * np.sqrt(x) + np.sin(y) * np.log(x) - np.exp(y) print(d.shape) print("--- %s sec ---" % (time.time() - starttime)) ```

| Scenario|MxNet CPU|NumPy| | --- |--- |---| | 1| 1.2247| 145.4460| | 2| 24.4994| 14.3616|

Nuget

Install the package: Install-Package MxNet.Sharp

https://www.nuget.org/packages/MxNet.Sharp

Add the MxNet redistributed package available as per below.

Important: Make sure your installed CUDA version matches the CUDA version in the nuget package.

Check your CUDA version with the following command: nvcc --version

You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version.

MxNet Version Build: https://github.com/apache/incubator-mxnet/releases/tag/1.5.0

Win-x64 Packages

| Type | Name | Nuget | |----------------|------------------------------------------|-------------------------------------------------| | MxNet-CPU | MxNet CPU Version | Install-Package MxNet.Runtime.Redist | | MxNet-MKL | MxNet CPU with MKL | Install-Package MxNet-MKL.Runtime.Redist | | MxNet-CU101 | MxNet for Cuda 10.1 and CuDnn 7 | Install-Package MxNet-CU101.Runtime.Redist | | MxNet-CU101MKL | MxNet for Cuda 10.1 and CuDnn 7 | Install-Package MxNet-CU101MKL.Runtime.Redist | | MxNet-CU100 | MxNet for Cuda 10 and CuDnn 7 | Install-Package MxNet-CU100.Runtime.Redist | | MxNet-CU100MKL | MxNet with MKL for Cuda 10 and CuDnn 7 | Install-Package MxNet-CU100MKL.Runtime.Redist | | MxNet-CU92 | MxNet for Cuda 9.2 and CuDnn 7 | Install-Package MxNet-CU100.Runtime.Redist | | MxNet-CU92MKL | MxNet with MKL for Cuda 9.2 and CuDnn 7 | Install-Package MxNet-CU92MKL.Runtime.Redist | | MxNet-CU80 | MxNet for Cuda 8.0 and CuDnn 7 | Install-Package MxNet-CU100.Runtime.Redist | | MxNet-CU80MKL | MxNet with MKL for Cuda 8.0 and CuDnn 7 | Install-Package MxNet-CU80MKL.Runtime.Redist |

Linux-x64 Packages

| Type | Name | Nuget | |----------------|------------------------------------------|---------------------------------------------------| | MxNet-CPU | MxNet CPU Version | Install-Package MxNet.Linux.Runtime.Redist | | MxNet-MKL | MxNet CPU with MKL | Install-Package MxNet-MKL.Linux.Runtime.Redist | | MxNet-CU101 | MxNet for Cuda 10.1 and CuDnn 7 | Yet to publish | | MxNet-CU101MKL | MxNet for Cuda 10.1 and CuDnn 7 | Yet to publish | | MxNet-CU100 | MxNet for Cuda 10 and CuDnn 7 | Yet to publish | | MxNet-CU100MKL | MxNet with MKL for Cuda 10 and CuDnn 7 | Yet to publish | | MxNet-CU92 | MxNet for Cuda 9.2 and CuDnn 7 | Yet to publish | | MxNet-CU92MKL | MxNet with MKL for Cuda 9.2 and CuDnn 7 | Yet to publish | | MxNet-CU80 | MxNet for Cuda 8.0 and CuDnn 7 | Yet to publish | | MxNet-CU80MKL | MxNet with MKL for Cuda 8.0 and CuDnn 7 | Yet to publish |

OSX-x64 Packages

| Type | Name | Nuget | |----------------|------------------------------------------|---------------------------------------------------| | MxNet-CPU | MxNet CPU Version | Yet to publish | | MxNet-MKL | MxNet CPU with MKL | Yet to publish | | MxNet-CU101 | MxNet for Cuda 10.1 and CuDnn 7 | Yet to publish | | MxNet-CU101MKL | MxNet for Cuda 10.1 and CuDnn 7 | Yet to publish | | MxNet-CU100 | MxNet for Cuda 10 and CuDnn 7 | Yet to publish | | MxNet-CU100MKL | MxNet with MKL for Cuda 10 and CuDnn 7 | Yet to publish | | MxNet-CU92 | MxNet for Cuda 9.2 and CuDnn 7 | Yet to publish | | MxNet-CU92MKL | MxNet with MKL for Cuda 9.2 and CuDnn 7 | Yet to publish | | MxNet-CU80 | MxNet for Cuda 8.0 and CuDnn 7 | Yet to publish | | MxNet-CU80MKL | MxNet with MKL for Cuda 8.0 and CuDnn 7 | Yet to publish |

Gluon MNIST Example

Demo as per: https://mxnet.apache.org/api/python/docs/tutorials/packages/gluon/image/mnist.html

```csharp var mnist = TestUtils.GetMNIST(); //Get the MNIST dataset, it will download if not found var batchsize = 200; //Set training batch size var traindata = new NDArrayIter(mnist["traindata"], mnist["trainlabel"], batchsize, true); var valdata = new NDArrayIter(mnist["testdata"], mnist["testlabel"], batch_size);

// Define simple network with dense layers var net = new Sequential(); net.Add(new Dense(128, ActivationType.Relu)); net.Add(new Dense(64, ActivationType.Relu)); net.Add(new Dense(10));

//Set context, multi-gpu supported var gpus = TestUtils.ListGpus(); var ctx = gpus.Count > 0 ? gpus.Select(x => Context.Gpu(x)).ToArray() : new[] {Context.Cpu(0)};

//Initialize the weights net.Initialize(new Xavier(magnitude: 2.24f), ctx);

//Create the trainer with all the network parameters and set the optimizer var trainer = new Trainer(net.CollectParams(), new Adam());

var epoch = 10; var metric = new Accuracy(); //Use Accuracy as the evaluation metric. var softmaxcrossentropyloss = new SoftmaxCELoss(); float lossVal = 0; //For loss calculation for (var iter = 0; iter < epoch; iter++) { var tic = DateTime.Now; // Reset the train data iterator. traindata.Reset(); lossVal = 0;

// Loop over the train data iterator.
while (!train_data.End())
{
    var batch = train_data.Next();

    // Splits train data into multiple slices along batch_axis
    // and copy each slice into a context.
    var data = Utils.SplitAndLoad(batch.Data[0], ctx, batch_axis: 0);

    // Splits train labels into multiple slices along batch_axis
    // and copy each slice into a context.
    var label = Utils.SplitAndLoad(batch.Label[0], ctx, batch_axis: 0);

    var outputs = new NDArrayList();

    // Inside training scope
    using (var ag = Autograd.Record())
    {
        outputs = Enumerable.Zip(data, label, (x, y) =>
        {
            var z = net.Call(x);

            // Computes softmax cross entropy loss.
            NDArray loss = softmax_cross_entropy_loss.Call(z, y);

            // Backpropagate the error for one iteration.
            loss.Backward();
            lossVal += loss.Mean();
            return z;
        }).ToList();
    }

    // Updates internal evaluation
    metric.Update(label, outputs.ToArray());

    // Make one step of parameter update. Trainer needs to know the
    // batch size of data to normalize the gradient by 1/batch_size.
    trainer.Step(batch.Data[0].Shape[0]);
}

var toc = DateTime.Now;

// Gets the evaluation result.
var (name, acc) = metric.Get();

// Reset evaluation result to initial state.
metric.Reset();
Console.Write($"Loss: {lossVal} ");
Console.WriteLine($"Training acc at epoch {iter}: {name}={(acc * 100).ToString("0.##")}%, Duration: {(toc - tic).TotalSeconds.ToString("0.#")}s");

} ```

Reached accuracy of 98% within 6th epoch.

alt text

Documentation (In Progress)

https://mxnet.tech-quantum.com/

Owner

  • Name: Deepak Battini
  • Login: deepakkumar1984
  • Kind: user
  • Location: Adelaide, Australia
  • Company: @tech-quantum @SciSharp @apache

Just cooking and tasting new technology😉 Author: https://www.tech-quantum.com/author/deepak

Citation (CITATION.cff)

cff-version: 1.1.0
message: If you use this software, please cite it as below.
authors:
  - family-names: Deepak
    given-names: Battini
title: MxNet Sharp
version: 1.6.0
date-released: 2020-07-04

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "description": "MxNet.Sharp is a CSharp binding coving all the Imperative, Symbolic and Gluon API's with an easy to use interface",
  "name": "MxNet.Shar",
  "codeRepository": "https://github.com/tech-quantum/MxNet.Sharp",
  "issueTracker": "https://github.com/tech-quantum/MxNet.Sharp/issues",
  "license": "https://github.com/tech-quantum/MxNet.Sharp/blob/master/LICENSE",
  "version": "1.5.1",
  "author": [
    {
      "@type": "Person",
      "givenName": "Deepak",
      "familyName": "Battini",
      "email": "deepakkumar1984@gmail.com",
      "@id": "https://orcid.org/0000-0003-1719-3091"
    }
  ],
  "developmentStatus": "active",
  "keywords": [
    "GitHub",
    "metadata",
    "software"
  ],
  "maintainer": "https://orcid.org/0000-0003-1719-3091",
  "programmingLanguage": "C#"
}

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 4,060
  • Total Committers: 5
  • Avg Commits per committer: 812.0
  • Development Distribution Score (DDS): 0.012
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
deepakkumar1984 d****4@g****m 4,013
horker h****r 27
Deepak Battini d****i@u****u 16
Taylor Koon t****n@g****m 3
sportbilly21 6****1 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 14
  • Total pull requests: 31
  • Average time to close issues: about 1 month
  • Average time to close pull requests: about 10 hours
  • Total issue authors: 6
  • Total pull request authors: 4
  • Average comments per issue: 2.86
  • Average comments per pull request: 0.61
  • Merged pull requests: 30
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • tk4218 (5)
  • evo11x (5)
  • deepakkumar1984 (1)
  • breadbyte (1)
  • sharpwood (1)
  • bitstormFA (1)
Pull Request Authors
  • horker (26)
  • tk4218 (3)
  • dependabot[bot] (1)
  • sportbilly21 (1)
Top Labels
Issue Labels
bug (2) no-issue-activity (2) enhancement (2) question (1)
Pull Request Labels
dependencies (1)

Packages

  • Total packages: 2
  • Total downloads:
    • nuget 9,785 total
  • Total dependent packages: 2
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 13
  • Total maintainers: 1
nuget.org: mxnet.sharp

C# Binding for the Apache MxNet library. NDArray, Symbolic and Gluon Supported MxNet is a deep learning framework designed for both efficiency and flexibility. It allows you to mix symbolic and imperative programming to maximize efficiency and productivity. At its core, MXNet contains a dynamic dependency scheduler that automatically parallelizes both symbolic and imperative operations on the fly. A graph optimization layer on top of that makes symbolic execution fast and memory efficient. MXNet is portable and lightweight, scaling effectively to multiple GPUs and multiple machines. MXNet is more than a deep learning project. It is a collection of blue prints and guidelines for building deep learning systems, and interesting insights of DL systems for hackers.

  • Versions: 12
  • Dependent Packages: 2
  • Dependent Repositories: 1
  • Downloads: 8,956 Total
Rankings
Stargazers count: 3.4%
Forks count: 5.9%
Dependent packages count: 6.8%
Dependent repos count: 7.0%
Average: 8.6%
Downloads: 19.8%
Maintainers (1)
Last synced: 4 months ago
nuget.org: mxnet.runtime.linux.redist

MxNet Linux CPU Redistributed package for MxNet.Sharp library.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 829 Total
Rankings
Stargazers count: 2.3%
Forks count: 3.6%
Dependent repos count: 12.7%
Average: 17.2%
Dependent packages count: 19.5%
Downloads: 48.1%
Maintainers (1)
Last synced: 4 months ago

Dependencies

examples/BasicExamples/BasicExamples.csproj nuget
examples/BostonHousingRegression/BostonHousingRegression.csproj nuget
examples/ConsoleTest/ConsoleTest.csproj nuget
examples/GluonCVExamples/GluonCVExamples.csproj nuget
  • MxNet.Runtime.Redist 1.6.0
examples/ImageClassification/ImageClassification.csproj nuget
  • MxNet-CU100.Runtime.Redist 1.5.0
examples/MNIST/MNIST.csproj nuget
examples/MxNetKerasExamples/MxNetKerasExamples.csproj nuget
  • MxNet.Runtime.Redist 1.6.0
examples/ORGate/ORGate.csproj nuget
  • MxNet.Runtime.Redist 1.5.0
src/CocoTools.NET/CocoTools.NET.csproj nuget
src/MxNet/MxNet.csproj nuget
  • CsvHelper 30.0.1
  • Microsoft.ML.OnnxRuntime 1.14.1
  • Newtonsoft.Json 13.0.3
  • NumpyDotNet 0.9.84
  • Onnx.Net 0.3.1
  • OpenCvSharp4.Windows 4.7.0.20230115
  • System.Memory 4.5.5
  • protobuf-net 3.2.16
src/MxNet.AutoGluon/MxNet.AutoGluon.csproj nuget
src/MxNet.GluonCV/MxNet.GluonCV.csproj nuget
src/MxNet.GluonNLP/MxNet.GluonNLP.csproj nuget
src/MxNet.GluonTS/MxNet.GluonTS.csproj nuget
src/MxNet.Keras/MxNet.Keras.csproj nuget
  • Flurl.Http 2.4.2
  • HDF.PInvoke.NETStandard 1.10.502
src/MxNet.Scikit/MxNet.SciKit.csproj nuget
tests/MxNet.Tests/MxNet.Tests.csproj nuget
  • Microsoft.NET.Test.Sdk 17.5.0
  • NUnit 3.13.3
  • NUnit3TestAdapter 4.4.2
vs_extensions/MxNet_Vs_Extension/MxNet_Vs_Extension/MxNet_Vs_Extension.csproj nuget