Skip to content

Menny1337/Neural-Network-p5

This branch is 7 commits behind shiffman/Neural-Network-p5:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

43dc04e · Jul 24, 2017

History

54 Commits
Jul 24, 2017
Apr 7, 2017
Apr 26, 2017
Apr 26, 2017
Jun 14, 2017

Repository files navigation

Simple Artificial Neural Network JavaScript library

This repository is a library for creating simple vanilla 3-layer ANNs in JavaScript. I'm using it for the second edition of the Nature of Code book, as well as examples for my ITP course: Intelligence and Learning.

At the moment this library is depends on p5.js. However, it's my intention to remove this dependency for the library itself (while still making examples using p5): #10. I also intend to port this library to Java for Processing: #11.

Finally, this library has a terribly inefficient matrix implementation and should likely include options for using math.js and/or gpu.js.

The code is based on the book Make Your Own Neural Network by Tariq Rashid (book source code).

Example Demos

The neuro-evolution examples are inspired by the chrome experiment Flappy Learning by xviniette.

Use

// Creating a Neural Network with # of inputs, hidden neurons, and outputs
var inputs = 4;
var hidden = 16;
var outputs = 2;
var nn = new NeuralNetwork(inputs, hidden, outputs);

// Training the Neural Network with inputs and known outputs
var inputs = [-0.3, 0.5, 0.3, 0.2];
var targets = [0.99, 0.01];
nn.train(inputs, targets);

// Querying the Neural Network with inputs
var inputs = [-0.3, 0.5, 0.3, 0.2];
var prediction = nn.query(inputs);

By default, the library will use a sigmoid activation function. However, you can select other activation functions as follows (tanh only at the moment)):

var nn = new NeuralNetwork(inputs, hidden, outputs, 'sigmoid');
var nn = new NeuralNetwork(inputs, hidden, outputs, 'tanh');

About

Simple Neural Network JavaScript library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%