GithubHelp home page GithubHelp logo

thomaoc1 / mnistnumpynet Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.61 MB

This is a simple implementation of a neural network from scratch using numpy. The neural network is trained on the MNIST dataset. The neural network uses backpropagation to update the weights.

Python 100.00%

mnistnumpynet's Introduction

Neural-Network from scratch using numpy

This is a simple implementation of a neural network from scratch using numpy. The neural network is trained on the MNIST dataset. The neural network uses backpropagation to update the weights.

Results

Training the model with 3 hidden layers of 200, 100, and 50 neurons respectively, a learning rate of 0.01, a batch size of 32, and 5 epochs, the model achieved an accuracy of ~96% on the test set.

This is what the training process looks like:

training.gif

The following is an example of the model's predictions on the test set:

example.png

Getting Started

This is if you would like to play with it yourself.

Prerequisites

Download the MNIST dataset from here. Extract the files and place them in a directory at the root level named dataset/MNNIST.

This is what it should look liked after extracting the files. The mnist_train.csv and mnist_test.csv files should be in the MNIST directory under datasets

root
├── README.md
├── datasets
│   ├── MNIST
│   │   ├── mnist_test.csv
│   │   └── mnist_train.csv
├── requirements.txt
├── res
│   └── ...
└── src
    └── ...

Installing

To install the required packages, run the following command:

python -m venv venv
pip3 install -r requirements.txt

Running

python3 -m src.main [-h] [-hl HIDDEN_LAYERS [HIDDEN_LAYERS ...]] [-lr LEARNING_RATE] [-bz BATCH_SIZE] [-e EPOCHS]

options:
  -h, --help            show this help message and exit
  -hl HIDDEN_LAYERS [HIDDEN_LAYERS ...]
                        Hidden layers ex: 200 100
  -lr LEARNING_RATE     Learning rate
  -bz BATCH_SIZE        Batch size
  -e EPOCHS             Epochs

For example (the default):

python3 -m src.main -hl 200 100 -lr 0.01 -bz 32 -e 5

Further Work

  • Generalise the model to work with any dataset
  • Add more activation functions
  • Add more loss functions

mnistnumpynet's People

Contributors

thomaoc1 avatar

Watchers

 avatar

mnistnumpynet's Issues

Big issue

Issue : Too boring
Recommended fix : Add some security to it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.