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.
- ✅ Feedforward neural network (MLP)
- ✅ Manual backpropagation implementation
- ✅ Learns XOR from scratch
- ✅ Only uses
randcrate — no ML dependencies - ✅ Fully commented and beginner-friendly
The XOR logic gate:
| Input A | Input B | Expected Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
git clone https://github.com/your-username/rust-xor-mlp.git cd rust-xor-mlp cargo run --releaseYou 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 rateInput: [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)