Skip to content

mike1393/simple-neural-network-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-neural-network-python

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:

📚 Data

The dataset used in this repo is the famous 🎉MNIST dataset🎉

📂 File Structure

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

💻 Virtual Environment

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

💥 Neural Network

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.

📈 Results

  • 6 images that performs the best
    Best 6
  • 6 images that performs the worst
    Worst 6

About

This repo demonstrates how I built a neural network from scratch using only Python and Numpy

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages