https://github.com/magnushelliesen/neural-network
Homemade neural network-class with a train/backpropagation method.
https://github.com/magnushelliesen/neural-network
artificial-neural-networks backpropagation linear-algebra machine-learning neural-networks object-oriented-programming stochastic-gradient-descent unit-testing
Last synced: 3 months ago
JSON representation
Homemade neural network-class with a train/backpropagation method.
- Host: GitHub
- URL: https://github.com/magnushelliesen/neural-network
- Owner: magnushelliesen
- License: mit
- Created: 2023-11-19T14:55:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-08T09:01:16.000Z (over 1 year ago)
- Last Synced: 2025-03-08T09:32:18.527Z (over 1 year ago)
- Topics: artificial-neural-networks, backpropagation, linear-algebra, machine-learning, neural-networks, object-oriented-programming, stochastic-gradient-descent, unit-testing
- Language: Jupyter Notebook
- Homepage:
- Size: 86 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# neural-network
I've built a [neural network-class](https://github.com/magnushelliesen/neural-network/blob/main/neural_network/neural_network.py) (from first principles, i.e., calculus and linear algebra only, using NumPy) with a train/backpropagation method and everything.
The class can be installed using
```python
pip install git+https://github.com/magnushelliesen/neural-network.git
```
The class seems to be able to train on the [MNIST dataset](https://git-disl.github.io/GTDLBench/datasets/mnist_datasets/) (see [notebook](https://github.com/magnushelliesen/neural-network/blob/main/notebooks/demo-neural-network-mnist-test.ipynb)), it recognizes most (but not all) handwritten digits. Look how effortlessly it recognizes even this squiggly "9":

It was a lot of tinkering to get it flying, lemme tell ya! What did the trick was to switch from batch gradient descent to stochastic gradient descent (and removing som bugs/errors). This is really cool!
I'm considering renaming this project/class "SonOfAnton" (for those who get the reference).

## Testing
This repo is set up with two GitHub Actions to make sure I don't merge code that breaks stuff into main:
1. A [GitHub Action](https://github.com/magnushelliesen/neural-network/blob/main/.github/workflows/run-tests.yml) that runs unit tests on the class upon PR into main
2. A [GitHub Action](https://github.com/magnushelliesen/neural-network/blob/main/.github/workflows/pre-commit-checks.yml) that runs Mypy and Black upon PR into main
## Neural network app
A pre-trained instance of the class is hosted on [Google Cloud Run](https://handwritten-digit-recognizer-app-569320861368.asia-east1.run.app/) and provides a nifty user interface.