← all repositories
ahmedfgad/NumPyCNN

A CNN that barely learns, on purpose

NumPy-only forward pass with no backprop, designed to be trained by genetic algorithms instead of gradient descent.

599 stars Python ML FrameworksComputer Vision
NumPyCNN
Velocity · 7d
+0.2
★ / day
Trend
steady
star history

What it does

NumPyCNN implements convolutional neural networks from scratch in a single cnn.py module, using only NumPy. It handles the full forward pass—convolution, ReLU, pooling, flatten, dense layers—enough to run classification on single-label samples. But there’s a catch: no backpropagation, no real learning algorithm. Just a learning rate nudging weights after each epoch, which the author notes is “better than leaving the weights unchanged.”

The interesting bit

The project is deliberately half-finished: it’s a skeleton waiting for a brain transplant. The intended brain is PyGAD, a genetic algorithm library by the same author, meant to evolve CNN weights instead of training them with gradients. That’s an unusual hybrid—deep learning architecture meets evolutionary computation.

Key highlights

  • Pure NumPy implementation, no TensorFlow or PyTorch dependencies
  • Single-file module (cnn.py) with all layer classes
  • Supports Conv2D, pooling, ReLU/Sigmoid, flatten, and dense layers
  • Designed for integration with PyGAD genetic algorithm training
  • Includes example code for building and running a model

Caveats

  • Forward pass only; current “training” is essentially weight perturbation, not meaningful learning
  • Single-label classification only
  • README is mostly PyGAD documentation and donation links; CNN-specific details are sparse
  • Genetic algorithm training appears aspirational—no working GA-CNN example shown in the README

Verdict

Worth a look if you’re curious about CNN internals or want to experiment with neuroevolution. Skip it if you need something that actually trains today, or if you want modern autograd and GPU support.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.