Artificial Neural Network
  • JavaScript 100%
Find a file
2016-08-23 01:05:11 -04:00
dist put build files in dist folder 2016-06-26 01:41:39 -04:00
docs learning link 2016-07-02 13:31:33 -04:00
examples Serialize / save 2016-07-04 16:15:56 -04:00
game Calculate fitness with Elo rating system. 2016-08-23 01:05:11 -04:00
lib Setup network class 2016-07-06 00:29:19 -04:00
spec/neural-networks Move console tests into specs 2016-07-02 14:17:29 -04:00
.gitattributes 👾 Added .gitattributes & .gitignore files 2016-06-24 19:24:05 -04:00
.gitignore change git ignore settings 2016-06-26 01:41:39 -04:00
.istanbul.yml Setup build / test scripts with gulp 2016-06-26 01:41:39 -04:00
.nvmrc set node version 2016-06-26 01:41:39 -04:00
bower.json setup bower/npm package descriptions 2016-06-26 01:41:39 -04:00
gulpfile.js Setup build / test scripts with gulp 2016-06-26 01:41:39 -04:00
LICENSE.md Add license 2016-06-26 01:41:39 -04:00
package.json separate ai players 2016-07-10 20:56:44 -04:00
README.md Mention/define deep network 2016-07-02 15:53:24 -04:00
run.js remove dead code, add note to self 2016-07-04 19:03:41 -04:00

Artificial Neural Network (ANN)

A project of curiosity learning about artificial neural networks.

API

Creating a network

let algorithm = create(4, 5, 3);
// input layer has 4 nodes
// hidden layer has 5 nodes
// output layer has 3 nodes

Must provide at least 3 size parameters for an input, hidden, and output layer.

You may create deep networks (multiple hidden layers) by providing more sizes. create(4, 5, 5, 3)

Initial weights and bias will be pre-populated.

Reading values

Get a list of all weights/biases used to define the algorithm used for mutations, crossovers, and duplication.

let values = reader(algorithm);
// [
// 0.4987250047589621,
// 0.5012749952410379,
// ...
// ]

Writing values

Replace the weights/biases used to define the target algorithm.

 writer(algorithm, values);

Copying an algorithm

let a = create(4, 5, 3),
  b = create(4, 5, 3),
  values = reader(a);
writer(b, values);
// b has same values as a!

Running the algorithm

Moves the values through each layer and applies weights, biases, and activates each layer.

The values of the first layer must be set first. The last layers values will contain the results.

let algorithm = create(4, 5, 3);
algorithm[0].values = [3.4, 0.1, 1, 0.333];
let output = runner(algorithm);
// [0.1, 0.3, 0.6]

Algorithm

An algorithm is made of multiple layers. It is represented as an array of layers. Calculations are done between two layers in sequential order.

[
  inputLayer,
  hiddenLayer1,
  // ...
  hiddenLayerN,
  outputLayer
]

Layer

A layer represents ... a layer. Each node within the layer has a weight that is applied to each node in the next layer. In addition, each node in the layer has a bias that is applied to all incoming values.

{
  values: [nodeCount],
  weights: [nodeCount][nextNodeCount],
  biases: [nodeCount],
  activation: 'htan|softmax|sigmoid|heviside'
}
  • values: Represents the values coming into the layer.
  • weights: A weight to be applied to the next layers value. Each value has a weight applied to each of the next layers values. The last layer does not use weights.
  • biases: A bias applied to the incoming values before weights are applied. The first layer does not use biases.
  • activation: The function applied to each value in the layer after the previous layer has applied its bias and weights. (The first layer does not get activated.)
    • softmax: The softmax function is applied to all values as a whole. (Typically for the last layer.)
    • htan: The Hyperbolic Tangent is applied to each individual value. (Typically for all layers except the last)
    • heaviside: Applied to individual values.
    • sigmoide: Applied to individual values.
    • [empty]: No threshold is applied.