victorqribeiro / MLP

Licence: MIT license
A multilayer perceptron in JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language
python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to MLP

dl-relu
Deep Learning using Rectified Linear Units (ReLU)
Stars: ✭ 20 (+33.33%)
Mutual labels:  multilayer-perceptron
pydata-london-2018
Slides and notebooks for my tutorial at PyData London 2018
Stars: ✭ 22 (+46.67%)
Mutual labels:  multilayer-perceptron
mlp-gpt-jax
A GPT, made only of MLPs, in Jax
Stars: ✭ 53 (+253.33%)
Mutual labels:  multilayer-perceptron
g-mlp-pytorch
Implementation of gMLP, an all-MLP replacement for Transformers, in Pytorch
Stars: ✭ 383 (+2453.33%)
Mutual labels:  multilayer-perceptron
digitRecognition
Implementation of a digit recognition using my Neural Network with the MNIST data set.
Stars: ✭ 21 (+40%)
Mutual labels:  multilayer-perceptron

MLP - Multilayer Perceptron

A multilayer perceptron implementation in JavaScript.

About

This is my implementation of a MLP in JavaScript. It's comes along with a matrix library to help with the matrix multiplications. Right now the code is untested and only with basic checks, but I'm still working on it. There's a s variable commented out in the code, it can be used to measure the error over iterations. The error should get smaller as the MLP gets trained. The dataset used in the html example was taken from here.

How to use

Let's suppose you have the following data set:

Height (cm) Weight (kg) Class (0-1)
180 80 0
175 67 0
100 30 1
120 32 1

0 - adult
1 - child

You need to process the table to this format:

const x = [
	[180, 80],
	[175, 67],
	[100, 30],
	[120, 32]
];

const y = [
	[1,0],
	[1,0],
	[0,1],
	[0,1]
];

Note that different from my perceptron the labels are now one-hot encoded

Then just create a new MLP passing the number of inputs, the number of nodes in the hidden layer, the number of outputs, the learning rate and the number of iterations.

const nn = new MLP( x[0].length, x[0].length * 2, 2, 0.03, 500 );

Call the fit function

nn.fit( x, y );

And you're all set to make predictions

nn.predict( [178, 70] )

There's also a shuffle function that can be used before the training.

nn.shuffle( x, y );

Applications

I trained my neural network to detect when I'm in front of the PC.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].