Skip to content

rust-dd/xor-neural-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Tiny XOR Neural Network in Rust

A minimalist, fully handcrafted neural network built in pure Rust — trained to solve the classic XOR problem. No frameworks, no magic — just neurons, layers, and backpropagation.

Rust NeuralNet


✨ Features

  • ✅ Feedforward neural network (MLP)
  • ✅ Manual backpropagation implementation
  • ✅ Learns XOR from scratch
  • ✅ Only uses rand crate — no ML dependencies
  • ✅ Fully commented and beginner-friendly

🧠 What it learns

The XOR logic gate:

Input A Input B Expected Output
0 0 0
0 1 1
1 0 1
1 1 0

🚀 Getting Started

git clone https://github.com/your-username/rust-xor-mlp.git
cd rust-xor-mlp
cargo run --release

🔧 Configuration

You can tweak the training parameters in main.rs:

let mut network = Network::new(2, 2); // hidden layer size
network.train(100_000, 0.1); // epochs, learning rate

📈 Sample Output (after training)

Input: [0.0, 0.0] → Output: 0.02 (Expected: 0)
Input: [0.0, 1.0] → Output: 0.97 (Expected: 1)
Input: [1.0, 0.0] → Output: 0.98 (Expected: 1)
Input: [1.0, 1.0] → Output: 0.03 (Expected: 0)

About

A minimal neural network that learns XOR from scratch using only the Rust standard library + rand.

Topics

Resources

Stars

Watchers

Forks

Languages