I built this python project to make sure that I REALLY understand of how neural networks work.
I followed the tutorials from 3Blue1Brown and Yujian Tang. So be sure to check them out if you are interested in this work.:thumbsup:
The dataset used in this repo is the famous 🎉MNIST dataset🎉
The file structure of the repo:
.
├─data
│ └─mnist.pkl.gz
│
├─neural_network
│ ├─activation_function.py
│ ├─neural_network.py
│ ├─data_loader.py
│ └─__init__.py
│
├─result
│ ├─hidden30_sigmoid_best_6.png
│ ├─hidden30_sigmoid_worst_6.png
│ └─model_pkl
│
├─find_best_and_worst.py
├─save_model.py
├─Pipfile
├─Pipfile.lock
├─README.md
The virtual environment was made with pipenv
The environment setting is listed in ./Pipfile and ./Pipfile.lock.
Follow the guide here if you want to learn pipenv
This is a simple implementation of a fully connected neural network.
The detailed implementation was in ./neural_network/neural_network.py.
The user specifies two inputs to create the neural network object.
The first one is the structure of your network using a list of integers, where each number represents the number of neurons for each layer.
The second one is the type of activation function. The implementation can be found at ./neural_network/activation_function.py
- For example, if we want to craete a network with 2 hidden layers, each hidden layer consists of 16 neurona.
And all layers use sigmoid function as activation function.
from neural_network.neural_network import NeuralNetwork
import neural_network.activation_function as af
net = NeuralNetwork([784,16,16,10], af.SIGMOID)
Check out save_model.py or find_best_and_worst.py to see more examples on how to use the pacakge.