Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convolutional Neural Network from Scratch in NumPy

A 2D Convolutional Neural Network (CNN) framework implemented from first principles in NumPy, without relying on PyTorch or TensorFlow for model operations or automatic differentiation.

This project was originally created upon finishing high school as an early programming project to learn Python and understand neural network mathematics. The original unedited state is tagged as v0.1.0-legacy (commit 5cdbe1f) and preserved in legacy/original_cnn.py. The repository contains both that original implementation and a modernized refactor with modular layer abstractions, type annotations, unit tests, and vectorized im2col acceleration.


Visualizations

Intermediate Feature Maps

Visualizing layer outputs shows how convolution filters detect edge primitives and feature boundaries:

Layer 1 Feature Maps (16 Filters) Layer 2 Feature Maps (32 Filters)
Layer 1 Feature Maps Layer 2 Feature Maps

Achieves 95% validation accuracy and 98% validation accuracy.


Quickstart & Usage

This project uses uv for dependency management.

  1. Install dependencies:
uv sync
  1. Run the train script:
uv run train.py
  1. Generate the plots:
uv run visualize.py

About

Implementation of Convolutional Neural Network from scratch

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages