Skip to content
mxnetlib is a CSharp binding coving all the Imperative and Symbolic API's with an easy to use interface. Also developed a high level interface to build and train model.
C#
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Adding files for first time May 2, 2019
examples Updated DataFrame Constructor Jun 7, 2019
src Updated DataFrame Constructor Jun 7, 2019
.gitattributes Adding files for first time May 2, 2019
.gitignore
.travis.yml Adding files for first time May 2, 2019
CODE_OF_CONDUCT.md Adding files for first time May 2, 2019
CONTRIBUTING.md Adding files for first time May 2, 2019
LICENSE Initial commit May 2, 2019
MxNetLib.CSharp.sln .... May 9, 2019
README.md Update README.md May 10, 2019
desktop.ini Adding files for first time May 2, 2019
icon_32.PNG .... May 10, 2019
icon_512.jpg ... Jun 5, 2019
icon_64.PNG .... May 10, 2019

README.md

MxNet

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 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.

mxnetlib is a CSharp binding coving all the Imperative and Symbolic API's with an easy to use interface. Also developed a high level interface to build and train model.

Setup MxNet for Windows: https://github.com/deepakkumar1984/mxnetlib/wiki/Setup---Windows

Nuget

Install the package: Install-Package MxNetLib

https://www.nuget.org/packages/MxNetLib

Symbolic Example

model.SetInput(784);

var x = Symbol.Variable("X");
var fc1 = sym.Relu(sym.FullyConnected(x, Symbol.Variable("fc1_w"), 128));
var fc2 = sym.Relu(sym.FullyConnected(fc1, Symbol.Variable("fc2_w"), 128));
var fc3 = sym.FullyConnected(fc2, Symbol.Variable("fc3_w"), 10);
var output = sym.SoftmaxOutput(fc3, Symbol.Variable("label"), symbol_name: "model");

model.SetDefaultInitializer(new RandomUniform(-1, 1));
model.Compile(output, OptimizerRegistry.SGD(), MetricType.Accuracy);

High Level API Example

model.SetInput(784);

model.Add(new Dense(128, ActivationType.ReLU, kernalInitializer: new RandomUniform(-1, 1)));
model.Add(new Dense(128, ActivationType.ReLU, kernalInitializer: new RandomUniform(-1, 1)));
model.Add(new Dense(10));

model.Compile(OptimizerRegistry.SGD(), LossType.SoftmaxCategorialCrossEntropy, MetricType.Accuracy);

Train and Inference

//Training for 10 epoch
model.Fit(train, 10, batchSize, val);

//Load test data
ImageDataFrame frame = new ImageDataFrame(1, 28, 28);
frame.LoadImages("test_6.png", "test_4.png", "test_4.png", "test_6.png");
NDArray test = frame.ToVariable().Ravel() / 255;

// Predict
var prediction = model.Predict(test).Argmax();
Console.WriteLine(prediction.ToString());

Saving and Loading model and checkpoint

string modelFolder = "../../../model";
model.SaveModel(modelFolder);
model.SaveCheckpoint(modelFolder);

var loadedModel = Module.LoadModel(modelFolder);
loadedModel.LoadCheckpoint(modelFolder);
You can’t perform that action at this time.