This is a machine learning XOR logic using pure functional programming.
The network is a chain of matrix transformations. Every neuron is a tiny calculator performing:
-
Weights (
$W$ ): The synapses. Visualized as cyan (strong positive) and orange (strong negative) connections. -
Backpropagation: The math behind the magic. The network calculates the Gradient (
$\nabla C$ ) to determine how to nudge weights to reduce error. -
Cost Function: We use Mean Squared Error to quantify the "confusion":
$$MSE = \frac{1}{n} \sum (actual - predicted)^2$$
| Key | Action | Visual Feedback |
|---|---|---|
R |
Reset Brain | Scrambles weights; watch the loss graph spike. |
Watch |
Signal Flow | White sparks trace paths through high-weight connections. |
Analyze |
Loss Graph | The green line tracks "confusion." Flatline = Convergence. |
.
├── .github/
│ └── PULL_REQUEST_TEMPLATE.md
├── Assets/
│ └── NeuralNetwork.gif
├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── SECURITY.md
├── Main.hs
├── NeuralNet.hs
└── README.md
Get the Dependencies:
cabal update
cabal install glossBuild & Fire it up:
ghc -O2 Main.hs -o main
./main[!TIP] Running on a potato? If your FPS stutters, open
Main.hs, find thestepfunction, and change the training iterations from!! 10to!! 5. Your CPU will thank you.
Love this project? Whether it's fixing a bug or adding a new "brain" feature, your help is welcome!
- Check out the Contributing Guidelines.
- Read the Code of Conduct.
- Fork it and submit a PR!
If you discover any security-related issues, please review our Security Policy.
Built for educational purposes. This is a "vanilla" implementation—no heavy ML frameworks, no TensorFlow, no PyTorch. Just raw Haskell and pure math.
This project is licensed under the MIT License - see the LICENSE file for details.
Built by mazerissa
