Skip to content

Latest commit

 

History

32 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

5-Layer Neural Network

Deep Learning from Scratch, Visualized in Haskell

Neural Network Training Visualization

This is a machine learning XOR logic using pure functional programming.


The Engine (The Math)

The network is a chain of matrix transformations. Every neuron is a tiny calculator performing:

$$Output = \sigma(\sum(Input \cdot Weight) + Bias)$$

  • 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$$

Interactive Controls

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.

Project Structure

.
├── .github/
│   └── PULL_REQUEST_TEMPLATE.md
├── Assets/           
│   └── NeuralNetwork.gif
├── .gitignore        
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md      
├── LICENSE           
├── SECURITY.md          
├── Main.hs           
├── NeuralNet.hs      
└── README.md

Run it

Get the Dependencies:

cabal update
cabal install gloss

Build & Fire it up:

ghc -O2 Main.hs -o main
./main

[!TIP] Running on a potato? If your FPS stutters, open Main.hs, find the step function, and change the training iterations from !! 10 to !! 5. Your CPU will thank you.


Contributing

Love this project? Whether it's fixing a bug or adding a new "brain" feature, your help is welcome!

  1. Check out the Contributing Guidelines.
  2. Read the Code of Conduct.
  3. Fork it and submit a PR!

Security

If you discover any security-related issues, please review our Security Policy.


License & Disclaimer

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

About

This is a simple 5 layer Neural Network Made in pure functional programming in Haskell

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages