Javascript Implementation of Neural Networks

Overview

Network Implementation

function evaluate(layers, input){ let result = input; for(let i=0;i<layers.length;i++){ let layer = layers[i]; result = layer.evaluate(result); } return result; }

Backpropagation API

A neural network can be created using the backpropagation library. A network consists of an array of layers. Each layer follows the object description above. The library provides default implementations for a number of different layers.

The following code creates a neural network with one layer of weights with a bias, following by the relu activation function.

The evaluate method in the library will calculate the output of the network given an input.
let layers = []; layers.push(ba.affine([[1,1]], [[1]])); layers.push(ba.relu()); let input = [[1],[4]]; let test = evaluate(layers, input);