Skip to content
This repository was archived by the owner on Apr 30, 2022. It is now read-only.

Repository files navigation

Sigma

Build Status (Master)Build Status (Development)Nuget (PreRelease)Nuget (PreRelease WPF)MyGet (PreRelease)MyGet (PreRelease WPF)MIT license

Rocket powered machine learning. Create, compare, adapt, improve - neural networks at the speed of thought.

Sigma was created to be a more plain and understandable machine learning framework. This is what it can do:

  • Input, Output, Dense, Dropout, Recurrent, SoftmaxCE / SquaredDiff cost layers
  • Gradient descent, Momentum, Adadelta, Adagrad optimisers
  • Hooks for storing / restoring checkpoints, timekeeping, stopping (or doing other things) on certain criteria, computing and reporting runtime metrics
  • Easy addition of new layers with functional automatic differentiation
  • Linear and non-linear networks with arbitrarily connected constructs
  • Distributed multi- and single- CPU and GPU (CUDA) backends
  • Native graphical interface where parameters can be set and monitored in real-time

Installation

NuGet [Recommended]

The recommended way to use the latest version of Sigma is adding the NuGet package to your project. You can either include the core framework (command line only) Nuget (PreRelease) or the WPF visualiser (only works on Windows) which also references the core framework Nuget (PreRelease WPF).

In both cases, you can use any project with a main (e.g. ConsoleApplication) but you have to change the project settings to x64 (since Sigma only supports 64bit mode) and change the target framework to .NET 4.6 before installing the NuGet packages.

Change .NET Version (Visual Studio)

Right click the project in the solution explorer and click Properties. Then in the tab Application, change the Target framework to .NET 4.6.

Change to x64 (Visual Studio)

In the navigation bar, click on Any CPU and select Configuration Manager. In the configuration manager, click the Platform dropdown and choose new. Change the New platform to x64 and click OK and close.

From source

For extensive customisation you can also install Sigma from source. This is not recommended as it may be outdated and unstable, but you still might want to do it for whatever reason. First, clone from the GitHub repository - use master for stable releases, development for recent and possibly unstable changes and fixes:

git clone https://github.com/ThinkingTransistor/Sigma

Restore and add all used NuGet packages (also see Used libraries) in the project folder (Sigma by default):

cd Sigma
nuget restore Sigma.sln

You can then integrate Sigma directly into your program as a project reference.

First program - Classic MNIST (Sigma.Core)

An example trainer to classify handwritten digits from the MNIST dataset, using dense (fullyconnected) and dropout layers with a Softmax / Cross Entropy cost layer. Using a GTX 1080 and the CUDA backend, this simple trainer reaches 94.7% test accuracy after ~4 seconds (1 epoch), 97.0% after ~25 seconds (5 epochs + test time) and peaks at 97.6% after ~50 seconds (10 epochs + test time).

For this program, the Sigma.Core NUGET package is requird.

SigmaEnvironment.EnableLogging();SigmaEnvironmentsigma=SigmaEnvironment.Create("mnist");IDatasetdataset=Defaults.Datasets.Mnist();// datasets are automatically downloaded and unpacked if not on diskITrainertrainer=sigma.CreateTrainer("mnist-trainer");trainer.Network.Architecture=InputLayer.Construct(28,28)+DropoutLayer.Construct(0.2)+FullyConnectedLayer.Construct(1000,activation:"rel")+DropoutLayer.Construct(0.4)+FullyConnectedLayer.Construct(800,activation:"rel")+DropoutLayer.Construct(0.4)+FullyConnectedLayer.Construct(10,activation:"sigmoid")+OutputLayer.Construct(10)+SoftMaxCrossEntropyCostLayer.Construct();trainer.TrainingDataIterator=newMinibatchIterator(100,dataset);trainer.AddNamedDataIterator("validation",newUndividedIterator(Defaults.Datasets.MnistValidation()));trainer.Optimiser=newAdagradOptimiser(baseLearningRate:0.02);trainer.Operator=newCpuSinglethreadedOperator();// change this line to a new CudaSinglethreadedOperator() if you have an NVIDIA GPU// Of course, CUDA has to be installed in order to work.trainer.AddInitialiser("*.weights",newGaussianInitialiser(standardDeviation:0.1));trainer.AddInitialiser("*.bias*",newGaussianInitialiser(standardDeviation:0.05));trainer.AddLocalHook(newValueReporter("optimiser.cost_total",TimeStep.Every(1,TimeScale.Iteration),reportEpochIteration:true).On(newExtremaCriteria("optimiser.cost_total",ExtremaTarget.Min)));trainer.AddHook(newMultiClassificationAccuracyReporter("validation",TimeStep.Every(1,TimeScale.Epoch),tops:new[]{1,2,3}));trainer.AddLocalHook(newRunningTimeReporter(TimeStep.Every(10,TimeScale.Iteration),averageSpan:32));trainer.AddLocalHook(newRunningTimeReporter(TimeStep.Every(1,TimeScale.Epoch),averageSpan:4));trainer.AddGlobalHook(newStopTrainingHook(atEpoch:10));sigma.PrepareAndRun();

First program - Classic MNIST (Sigma.Core.WPF)

This is the same program as above, only with visualisation activated.

For this program, the Sigma.Core.WPF NUGET package is requird.

SigmaEnvironment.EnableLogging();SigmaEnvironmentsigma=SigmaEnvironment.Create("mnist");IDatasetdataset=Defaults.Datasets.Mnist();// datasets are automatically downloaded and unpacked if not on diskITrainertrainer=sigma.CreateTrainer("mnist-trainer");trainer.Network.Architecture=InputLayer.Construct(28,28)+DropoutLayer.Construct(0.2)+FullyConnectedLayer.Construct(1000,activation:"rel")+DropoutLayer.Construct(0.4)+FullyConnectedLayer.Construct(800,activation:"rel")+DropoutLayer.Construct(0.4)+FullyConnectedLayer.Construct(10,activation:"sigmoid")+OutputLayer.Construct(10)+SoftMaxCrossEntropyCostLayer.Construct();trainer.TrainingDataIterator=newMinibatchIterator(100,dataset);trainer.AddNamedDataIterator("validation",newUndividedIterator(Defaults.Datasets.MnistValidation()));trainer.Optimiser=newAdagradOptimiser(baseLearningRate:0.02);trainer.Operator=newCpuSinglethreadedOperator();// change this line to a new CudaSinglethreadedOperator() if you have an NVIDIA GPU// Of course, CUDA has to be installed in order to work.trainer.AddInitialiser("*.weights",newGaussianInitialiser(standardDeviation:0.1));trainer.AddInitialiser("*.bias*",newGaussianInitialiser(standardDeviation:0.05));trainer.AddLocalHook(newValueReporter("optimiser.cost_total",TimeStep.Every(1,TimeScale.Iteration),reportEpochIteration:true).On(newExtremaCriteria("optimiser.cost_total",ExtremaTarget.Min)));trainer.AddHook(newMultiClassificationAccuracyReporter("validation",TimeStep.Every(1,TimeScale.Epoch),tops:new[]{1,2,3}));trainer.AddLocalHook(newRunningTimeReporter(TimeStep.Every(10,TimeScale.Iteration),averageSpan:32));trainer.AddLocalHook(newRunningTimeReporter(TimeStep.Every(1,TimeScale.Epoch),averageSpan:4));WPFMonitorgui=sigma.AddMonitor(newWPFMonitor("My first Sigma application"));gui.AddTabs("Overview","Validation");gui.ColourManager.Dark=true;gui.WindowDispatcher(window =>{window.TabControl["Overview"].GridSize=newGridSize(2,3);window.TabControl["Overview"].AddPanel(newControlPanel("Control",trainer),0,0,2);varcost=newTrainerChartPanel<CartesianChart,GLineSeries,GearedValues<double>,double>("Cost / Epoch",trainer,"optimiser.cost_total",TimeStep.Every(25,TimeScale.Iteration)).Fast().Linearify();cost.MaxPoints=50;varaccuracy=newAccuracyPanel("Validation Accuracy",trainer,TimeStep.Every(1,TimeScale.Epoch),null,1,2);window.TabControl["Overview"].AddPanel(cost,0,1,1,2);window.TabControl["Overview"].AddPanel(accuracy,1,1,1,2);NumberPaneloutputpanel=newNumberPanel("Numbers",trainer);DrawPaneldrawPanel=newDrawPanel("Draw",trainer,560,560,20,outputpanel);window.TabControl["Validation"].GridSize=newGridSize(2,4);window.TabControl["Validation"].AddCumulativePanel(drawPanel,2,3);window.TabControl["Validation"].AddCumulativePanel(outputpanel,2);});// the operators should not run instantly but when the user clicks playsigma.StartOperatorsOnRun=false;sigma.PrepareAndRun();

Output

Example output of overview panelExample output of validation panel

Documentation - how do I?

The API-Documentation (of the master-branch) is always available at our Github-Page. If you want it locally available, clone the gh-pages branch.

Acknowledgements

The completion of this project would not have been possible without the assistance and support of many generous people. We cannot express enough thanks and gratefully acknowledge their contributions. In particular, we would like to express our deep gratitude and appreciation to the following:

  • Prof. Dr. Patrick van der Smagt, thank you. Thank you for your continued support and never-ending assistance. Thank you for your heartfelt encouragement and inspirational enthusiasm. Thank you for helping us out at midnight on a Saturday evening---we deeply appreciate your time, kindness, and efforts as our advisor.

  • To our family, friends, and loved ones, we thank you for your support and gratefully acknowledge your assistance in making this project become a reality.

  • To NVIDIA, for generously supporting us with two GTX 1080 for developing a CUDA backend operator.

  • To JetBrains, for granting an open source license, allowing us to improve code quality with Resharper.

We thank you.

Used libraries

For reference, a list of all libraries used in the Sigma project. The following libraries / frameworks are used in the core:

LibraryPurpose
log4netLogging (log4j for .NET)
NUnitUnit testing
DiffSharp, Sigma.DiffSharpFunctional automatic differentiation with ndarrays and various backends
SharpZipLibCompression and decompression of various formats (zip, tar, gz, bzip, gzip)
ManagedCuda, ManagedCuda-CUBLASManaged CUDA (GPU) and CuBLAS support

The following libraries are used in the graphical and interactive visualiser:

LibraryPurpose
DragablzTearable tab control for WPF, which includes docking, tool windows
LiveCharts, LiveCharts.WpfCharting, graphing, advanced data, plotting
MahApps.Metro, MahApps.Metro.ResourcesToolkit for creating metro-style WPF applications
MaterialDesignColors, MaterialDesignThemes, MaterialDesignThemes.MahAppsMaterial design for WPF/MahApps

About

Rocket powered machine learning. Create, compare, adapt, improve - artificial intelligence at the speed of thought.

Topics

Resources

Stars

121 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages