Skip to content
/ CNN Public

Implementation of a convolutional neural network (CNN) from scratch using NumPy, without TensorFlow or PyTorch. Trains on the MNIST dataset with a custom convolution layer, ReLU, softmax, and backpropagation. Training and hyperparameter tuning still in progress.

Notifications You must be signed in to change notification settings

t3i8m/CNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convolutional Neural Network for MNIST Digit Recognition

image Source: Medium article by Abhishek Jain

This project implements a Convolutional Neural Network (CNN) from scratch (without Keras/TensorFlow/PyTorch) to classify handwritten digits from the MNIST dataset.

🧠 Project Goal

To better understand how convolutional neural networks work under the hood by building one from scratch without high-level ML frameworks.

📁 Project Structure

CNN/
├── checkpoints/ # Saved model weights 
├── data/
│ └── mnist.pkl.gz # Compressed MNIST data file
├── model/
│ ├── CNN.py # Main CNN architecture
│ ├── ConvLayer.py # Custom convolutional layer
│ ├── init.py
│ └── FFNN/
│ └── NN.py # Fully-connected network 
├── utils/
│ ├── activation_loss.py # Activation functions and loss functions
│ ├── mnist_loader.py # MNIST data loader
│ ├── init.py
├── main.py # Entry point for training and evaluation
├── training.py # Training loop

📦 Requirements

  • Python 3.7+
  • NumPy
  • gzip, pickle (from Python standard library)

To install the required packages: pip install numpy

🚀 How to Run

  1. Make sure mnist.pkl.gz is present in the data/ folder.
  2. Run training: python main.py

✅ Features

  • Custom implementation of convolutional layers
  • Custom implementation for both CNN and FFNN architectures
  • MNIST digit classification
  • Modular and extensible codebase

⚠️ Training and hyperparameter tuning are still in progress. Results shown are preliminary.

About

Implementation of a convolutional neural network (CNN) from scratch using NumPy, without TensorFlow or PyTorch. Trains on the MNIST dataset with a custom convolution layer, ReLU, softmax, and backpropagation. Training and hyperparameter tuning still in progress.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages