Faris-Abuali / digit-recognizer

Trying to build a Neural Network from scratch (no Tensorflow/Pytorch, just numpy & math)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handwritten Digit Recognition

Building a Neural Network from Scratch (no Tensorflow/Pytorch, just numpy & math)

General Overview

During this semester, I have been studying the Artificial Intelligence curriculum. I have learnt some interesting topics, such as the Artificial Neural Networks. I have had some experience with Python and machine learning basics, but I am still new to computer vision. Building this project from scratch was a perfect introduction to Computer Vision using artificial neural networks (ANN).

What is Handwritten Digit Recognition?

The handwritten digit recognition is the ability of computers to recognize human handwritten digits. It is a hard task for the machine because handwritten digits are not perfect and can be made with many different flavors. The handwritten digit recognition is the solution to this problem which uses the image of a digit and recognizes the digit present in the image.


I have made a PowerPoint presentation showing everything in detail. Kindly take a look at at it. It will help you grasp the concept much better πŸ‘‡
πŸ”— https://mega.nz/file/ilMmwajB#cvxWlmGEu969mOb8pTbj7WxT9hL4QTJ8UVK11OOs9i0

1. Problem Statement & Objective

  • My goal is to correctly identify digits from a dataset of tens of thousands of handwritten images.
  • The dataset is provided by: MNIST ("Modified National Institute of Standards and Technology"). It is one of the most popular datasets of computer vision.
    • This classic dataset of handwritten images has served as the basis for benchmarking classification algorithms.
    • As new machine learning techniques emerge, MNIST remains a reliable resource for researchers and learners alike.

img2

img3

2. Math Explanation

I implemented a two-layer neural artificial network and trained it on the MNIST digit recognizer dataset. It’s meant to be implemented from scratch in Pyton using only numpy library – to deal with lists/matrices – and basic math. This helped me understand the underlying math of neural networks better.

image

image

My neural network will have the following architecture

  • Input layer will have 784 units/neurons corresponding to the 784 pixels in each 28x28 input image
  • One Hidden layer with 10 neurons
  • Output layer with 10 output units (because there will be 10 possible classifications from 0,..9)

image

image

image

image

image

image

image

image

image

3. Coding it up

Here is a glimpse of the training set used to train our neural network: image
You can check out the file code.py for the complete code πŸ˜€

4. Results

image

image

image

image

...

image

image

Let's look at a couple of examples:

image

image

image

image

image

image

And that's it. If you found this repository interesting, kindly give it a star πŸŒŸπŸ˜‰

About

Trying to build a Neural Network from scratch (no Tensorflow/Pytorch, just numpy & math)


Languages

Language:Python 100.0%