dn2a
v0.2.0
Published
DN2A - Digital Neural Networks Architecture
Downloads
4
Maintainers
Readme
DN2A - Digital Neural Networks Architecture
About
DN2A is a set of highly decoupled JavaScript modules for Neural Networks and Artificial Intelligence development.
Each module is based on injection by configuration.
You can use a single module alone, more of them together or just the complete set.
DN2A main goal is to allow you to design, train and use without pain Single Neural Networks as well as very powerful Neural Networks Chains through which implement your Artificial Intelligence solution.
DN2A side goals are to simplify integration, to speed up training/querying, to allow clustering and to represent the architecture and the relative data of each Neural Network as a (re)combinable string strain that will be usable within genetics optimization techniques.
Features
- Modularized components: helps the development and the clear separation of concerns with great benefits for who wants to use mixed solutions.
- Configurable precision: helps to avoid the noise deriving from operation errors and default system precision limits with great improvement of the learning speed and performance stability.
- Configuration checker: helps to write less details about configuration and to keep compatibility with older version while the project evolves.
- StepByStep training: helps to train neural networks doing a single iteration over the passed information without trying to reach a specific parametric condition.
- StepByGoal training: helps to train neural networks doing a finite or infinite number of iterations over the passed information unless a specific parametric condition is reached.
- Continuous training: helps to train neural networks doing an infinite number of iterations over the passed information.
- TODO (Bios) Data normalization: helps to simplify the interaction within your real domain.
- TODO (Host) Networks composition: helps to create very effective architectures of multiple neural networks able to obtain advanced behaviours like in deep learning.
- TODO (Host) Computation parallelization: helps to improve the scalability of your whole system.
- TODO (Bios) Sessions intercommunication: helps to improve the scalability of your whole system.
Modules
Node (Neuron)
Module able to facilitate the representation of the data structure around Neurons and to hold relative common functionalities.
Link (Synapse)
Module able to facilitate the representation of the data structure around Synapses and to hold relative common functionalities.
Network (Neural Network or Cortical Column)
Module, available in different variations, able to use Neurons and Synapses to implement configurable and autonomous Neural Networks.
Available Network Types
- alpha: standard feed forward neural network with error back propagation controlled by layer dimensions, learning mode, learning rate, momentum rate, maximum allowed error and maximum number of epochs.
Host (Cerebrum)
Module for the management of multiple Neural Networks in terms of configuration/coordination, training/querying chaining and parallel computing.
Bios (Brain)
Module for the management of data normalization, integration/intercommunication with other external software and monitoring of the whole session.
Tutorials
Using in Node
To install the library through NPM:
npm install dn2a
Using in the Browser
To install the library through Bower:
bower install dn2a
Training and Querying a Single Network with default parametrization (ES5)
// Importation
var DN2A = require("dn2a");
// Instantiation
var neuralNetwork = new DN2A.NetworkAlpha();
// Training
var trainingPatterns = [
{
input: [0, 0],
output: [0]
},
{
input: [0, 1],
output: [1]
},
{
input: [1, 0],
output: [1]
},
{
input: [1, 1],
output: [0]
}
];
neuralNetwork.train(trainingPatterns);
// Querying
var inputPatterns = [
[0, 0],
[0, 1],
[1, 0],
[1, 1]
];
neuralNetwork.query(inputPatterns, function(queryingStatus) {
inputPatterns.forEach(function(inputPatten, inputPatternIndex) {
console.log("[" + inputPatterns[inputPatternIndex].join(", ") + "] => [" + queryingStatus.outputPatterns[inputPatternIndex].join(", ") + "]");
});
});
Training and Querying a Single Network with custom parametrization (ES5)
// Importation
var DN2A = require("dn2a");
// Instantiation
// The object expected by the constructor can specify properties that describe the neural network.
// The list of the valid properties together their accepted ranges and default values is reported in this README file.
// The object can be completely omitted and in this case default values are used for all properties.
var neuralNetwork = new DN2A.NetworkAlpha();
var neuralNetwork = new DN2A.NetworkAlpha({
layerDimensions: [2, 4, 4, 1],
learningMode: "continuous",
learningRate: 0.3,
momentumRate: 0.7,
maximumError: 0.005,
maximumEpoch: 20000,
dataRepository: {},
neuron: {
generator: DN2A.Neuron
},
synapse: {
generator: DN2A.Synapse
},
numbersPrecision: 32
});
// Training
var trainingPatterns = [
{
input: [0, 0],
output: [0]
},
{
input: [0, 1],
output: [1]
},
{
input: [1, 0],
output: [1]
},
{
input: [1, 1],
output: [0]
}
];
neuralNetwork.train(trainingPatterns);
// Querying
var inputPatterns = [
[0, 0],
[0, 1],
[1, 0],
[1, 1]
];
neuralNetwork.query(inputPatterns, function(queryingStatus) {
inputPatterns.forEach(function(inputPatten, inputPatternIndex) {
console.log("[" + inputPatterns[inputPatternIndex].join(", ") + "] => [" + queryingStatus.outputPatterns[inputPatternIndex].join(", ") + "]");
});
});
Training and Querying a Single Network with evolution feedback (ES5)
// Importation
var DN2A = require("dn2a");
// Instantiation
var neuralNetwork = new DN2A.NetworkAlpha();
// Training
// The object passed to the callback function contains information about the training process.
// The list of the valid properties together their accepted ranges and default values is reported in this README file.
var trainingPatterns = [
{
input: [0, 0],
output: [0]
},
{
input: [0, 1],
output: [1]
},
{
input: [1, 0],
output: [1]
},
{
input: [1, 1],
output: [0]
}
];
neuralNetwork.train(trainingPatterns, function(trainingStatus) {
console.log("Epoch: " + trainingStatus.elapsedEpochCounter);
});
// Querying
var inputPatterns = [
[0, 0],
[0, 1],
[1, 0],
[1, 1]
];
neuralNetwork.query(inputPatterns, function(queryingStatus) {
inputPatterns.forEach(function(inputPatten, inputPatternIndex) {
console.log("[" + inputPatterns[inputPatternIndex].join(", ") + "] => [" + queryingStatus.outputPatterns[inputPatternIndex].join(", ") + "]");
});
});
Training and Querying a Single Network through the Host (ES5)
// Importation
var DN2A = require("dn2a");
// Instantiation
var cerebrum = new DN2A.Cerebrum({
minds: [
{
name: "firstNeuralNetwork",
network: {
generator: DN2A.NetworkAlpha,
configuration: {
layerDimensions: [2, 4, 1],
learningMode: "continuous",
learningRate: 0.3,
momentumRate: 0.7,
maximumError: 0.005,
maximumEpoch: 1000,
dataRepository: {},
neuron: {
generator: DN2A.Neuron
},
synapse: {
generator: DN2A.Synapse
},
numbersPrecision: 32
}
},
inputsFrom: [
"cerebrum"
]
}
],
outputsFrom: [
"firstNeuralNetwork"
]
});
// Training
// The name expected as third parameter by the trainMind method specifies which specific mind to train
var trainingPatterns = [
{
input: [0, 0],
output: [0]
},
{
input: [0, 1],
output: [1]
},
{
input: [1, 0],
output: [1]
},
{
input: [1, 1],
output: [0]
}
];
cerebrum.trainMind(trainingPatterns, function(trainingStatus) {
console.log("Epoch: " + trainingStatus.elapsedEpochCounter);
}, "firstNeuralNetwork");
// Querying
// The name expected as third parameter by the queryMind method specifies which specific mind to query
var inputPatterns = [
[0, 0],
[0, 1],
[1, 0],
[1, 1]
];
cerebrum.queryMind(inputPatterns, function(queryingStatus) {
inputPatterns.forEach(function(inputPatten, inputPatternIndex) {
console.log("[" + inputPatterns[inputPatternIndex].join(", ") + "] => [" + queryingStatus.outputPatterns[inputPatternIndex].join(", ") + "]");
});
}, "firstNeuralNetwork");
Training and Querying an entire Networks Chain through the Host (ES5)
TODO
Training and Querying a Single Network through the Bios (ES5)
TODO
Training and Querying an entire Networks Chain through the Bios (ES5)
TODO
Creator
License
MIT