PitchHut
Log in / Sign up
miniNeuralNetwork
23 views
A tiny neural network that packs a powerful punch in JavaScript.
Pitch

MiniNeuralNetwork is a compact, fast AI solution created in JavaScript, with a footprint of less than 512 bytes. Easily define your learning rate and customize activation and gradient descent functions to train networks efficiently, whether it's for XOR or even recognizing handwritten digits. Discover the potential of machine learning in a sleek, minimalistic package.

Description

MiniNeuralNetwork is a lightweight, fast artificial neural network implemented in JavaScript, designed to fit in less than 512 bytes! This compact neural network enables developers to explore the fascinating world of machine learning with minimal overhead and maximum efficiency.

Features

  • Compact Size: Built to be exceptionally small, this JavaScript package is perfect for experiments and understanding neural networks without the bloat.
  • Customizable Functions: Users can define their own learning rate, activation functions, and gradient descent algorithms, allowing for flexible modeling of various neural network architectures.

Quick Start Guide

To get started with MiniNeuralNetwork, follow these simple steps to set up your neural network:

1. Customize Your Network

Define the learning rate and activate functions:

// Customization
// =============

// Learning rate
l = 0.3;

// Activation function (sigmoid)
f = (x => 1 / (1 + Math.E**-x));

// Gradient descent function
g = (y => y * (1 - y));

2. Initialize the Network

You can initialize the network with input, hidden, and output nodes using the following code:

// Init (input_nodes, hidden_nodes, output_nodes)
// ==============================================

I(2, 10, 1);

3. Train Your Network

Train the neural network by passing input data and target outputs in a loop:

// Train (input, target)
// =====================

for(i = 0; i < 50000; i++){ // Example: XOR network
  P([[0],[0]], [[0]])
  P([[1],[0]], [[1]])
  P([[0],[1]], [[1]])
  P([[1],[1]], [[0]])
}

4. Query the Network

Once trained, you can query the network with input data:

// Query (input)
// =============

P([[1],[0]]) // 0.99...
P([[1],[1]]) // 0.01...

Demo Links

Explore MiniNeuralNetwork through engaging demonstrations:

Additional Resources

Learn more about neural networks and improve your understanding with the following sources:

Acknowledgments

Special thanks to the contributors who have golfed and optimized this code: @MaximeEuziere, @JohnMeuser, @IrratixMusic.

With MiniNeuralNetwork, delve into the world of neural networks and embark on your machine learning journey today!