Ann.koryakinp
1.0.0
dotnet add package Ann.koryakinp --version 1.0.0
NuGet\Install-Package Ann.koryakinp -Version 1.0.0
<PackageReference Include="Ann.koryakinp" Version="1.0.0" />
paket add Ann.koryakinp --version 1.0.0
#r "nuget: Ann.koryakinp, 1.0.0"
// Install Ann.koryakinp as a Cake Addin
#addin nuget:?package=Ann.koryakinp&version=1.0.0
// Install Ann.koryakinp as a Cake Tool
#tool nuget:?package=Ann.koryakinp&version=1.0.0
Ann
Machine Learning library for .NET Core.
Installation
PM> Install-Package Ann.koryakinp
Basic Usage
Configure a Network by defining the structure and meta-parametres
var layerConfig = new LayerConfiguration()
.AddInputLayer(2)
.AddHiddenLayer(5)
.AddHiddenLayer(5)
.AddOutputLayer(1);
AddInputLayer()
,AddOutputLayer()
and AddHiddenLayer()
add layers to the network configuration with specified number of neurons.
A network must have one input, one output and any number of hidden layers.
var networkConfig = new NetworkConfiguration(layerConfig);
var model = new Network(networkConfig);
Train Model
double err1 = model.TrainModel(new List<double> { 0.25, 0.50 }, new List<double> { 1 });
double err2 = model.TrainModel(new List<double> { 0.75, 0.15 }, new List<double> { 0 });
double err3 = model.TrainModel(new List<double> { 0.60, 0.40 }, new List<double> { 1 });
First argument of the TrainModel
method accepts input values.
Second argument accepts output target values for a given training example.
Weights and biases will be adjasted using Stochastic Gradient Descent with Back Propagation alghorith.
Use Model
List<double> output = model.UseModel(new List<double> { 0.35, 0.45 });
UseModel()
accepts input values and performs forward-only pass, returns prediction of the model.
Save Model
After you done with trainig you can save the model in JSON file for a later use:
model.SaveModelToJson("network-configuration.json");
var model2 = new Network("network-configuration.json");
Advanced Configuration
Customizing activation function for agiven layer
AddHiddenLayer()
and AddOutputLayer()
have usefull overloads which allow for customization of the Activation function. Out of the box following activation functions supported: Logistic Sigmoid, Hyperbolic Tangent and Rectified Linear Unit.
AddHiddenLayer(10, ActivatorType.ReluActivator)
adds hidden layer with 10 neurons and Rectified Linear Unit activation function. If activation type is not provided the layer will use Logistic Sigmoid by default.
For further customization an implementation of the IActivator
interface can be provided.
Customizing Learning Rate, Momentum and Learning Rate Decay
If no custom configuration was provided a Network will fallback to 0.1 flat learning rate, with no momentum. There are two learning rate decay strategy supported out of the box: Exponential decay and Step decay. Step decay reduces the learning rate by some factor every few epochs. Exponential decay gradually reduces the learning rate in an exponential fashion. More info regarding the learning rate decy can be found here: http://cs231n.github.io/neural-networks-3/#anneal
An example of custom Network Configuration:
NetworkConfiguration nc = new NetworkConfiguration(lc)
{
Momentum = 0.9
LearningRateDecayer = new StepDecayer(0.1, 0.8, 1000),
};
For further customization you can provide custom implementation of the ILearningRateDecayer
interface.
Authors
Pavel koryakin koryakinp@koryakinp.com
License
This project is licensed under the MIT License - see the LICENSE.md for details.
Acknowledgments
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
.NET Core | netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard2.0 netstandard2.1 |
.NET Framework | net461 net462 net463 net47 net471 net472 net48 net481 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 10.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 1,065 | 12/28/2017 |
Initial release