/NNSharp

Library for running neural networks.

Primary LanguageC#MIT LicenseMIT

logo

Build status

license

A lightweight package for running pre-trained neural networks. For the detailed documentation see the NNSharp documentation.

Philosophy

This library was created in order to run pre-trained neural networks. Training is the most time consuming part of a deep learning framework. Probably C# is not the best for training neural networks. There are a lot of very good solution can be found like Tensorflow, CNTK, Theano, PyTorch, Sonnet ans so on. Most of them suit the Python programming language and mainly support Linux.

Therefore this library aims for using the weights and structure created with the above softwares and just run it in C# on Windows.

Installation

The package is available as a NuGet package from nuget.org. The current NuGet package was built on Windows8.1, Visual Studio 2015 and .Net Framework4.5.2.

Getting started

It is very easy to use the library. The master branch contains a python script named KerasModeltoJSON.py. It takes the created and compiled Keras model and the output file name as arguments. The json file can be created as follows:

import KerasModeltoJSON as js
wrt = js.JSONwriter(model, fname)
wrt.save()

Then in the C# program:

// Read the previously created json.
var reader = new ReaderKerasModel(filePath); 
SequentialModel model = reader.GetSequentialExecutor();

// Then create the data to run the executer on.
// batch: should be set in the Keras model.
Data2D input = new Data2D(height, width, channel, batch);

// Calculate the network's output.
IData output = model.ExecuteNetwork(input);

For the detailed documentation see the NNSharp documentation.

Plans and contributions

The roadmap of the development can be seen on the following picture:

roadmap

The first stage is almost finished. The C++ API is planned to be similar like the Keras API in Python but with some further extensions (concrete architectures, file readers from different library outputs, wrapper for threading etc.)

Bug: Please create an issue with the label bug. Recommending features: Just create an issue with the label question.

For the current tasks see the issues with the label enhancement. If you want to contribute to the development write a letter to the following address: adam.8.budai at gmail dot com.

Summary

This library aims for connecting the models trained in Python with Tensorflow, Theano, Pytorch, Sonnet with C#. It is able to run the models but training has no priority in this project.

Licence

This project runs under the MIT licence. You can use it in any Open Source project.