Neural Networks

Understanding the building blocks of AI through interactive examples and hands-on coding.

🧠 Try the Demo

The Basic Neuron

Neurons process inputs using weighted connections and apply activation functions.

Layered Structure

Neural networks stack layers - input, hidden, and output - to learn complex patterns.

Gradient Descent

Optimization algorithms adjust weights to minimize prediction errors over time.

Neural Network Demo - XOR Gate

              
              // Initialize network with brain.js
const net = new brain.NeuralNetwork();

// Train for XOR logic gate
net.train([
  {input: [0,0], output: [0]},
  {input: [0,1], output: [1]},
  {input: [1,0], output: [1]},
  {input: [1,1], output: [0]}
]);

// Test predictions
console.log('0,0 →', net.run([0,0]).toFixed(3));
console.log('0,1 →', net.run([0,1]).toFixed(3));
console.log('1,0 →', net.run([1,0]).toFixed(3));
console.log('1,1 →', net.run([1,1]).toFixed(3));
              
            

This simple network learns the XOR pattern through gradient descent optimization. The brain.js library handles weight updates automatically - try running the code!

Real-World Applications

Image Recognition

Deep learning models process visual data with convolutional networks

Natural Language

Transformers power language models by understanding word context

Game AI

Reinforcement learning builds agents that master complex environments