SkillAgentSearch skills...

CNNumpy

A Numpy implementation of a Convolutional Neural Network: slow & fast (im2col/col2im).

Install / Use

/learn @3outeille/CNNumpy
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<img src="./img/logo.png" hspace="20%" width="60%">

Introduction

  • CNNumpy is a Convolutional Neural Network written in pure Numpy (educational purpose only).
  • There are 2 implementation versions:
    • Slow: The naive version with nested for loops.
    • Fast: The im2col/col2im version.
  • The slow implementation takes around 4 hours for 1 epoch where the fast implementation takes only 6 min for 1 epoch.
  • For your information, with the same architecture using Pytorch, it will take around 1 min for 1 epoch.
  • For more details, here are my blog posts explaining in depth what's going on under the hood for each implementation (slow and fast).
  • In the demo-cnnumpy-fast.ipynb notebook, the im2col/col2im implementation can achieve an accuracy up to 97.2% in 1 epoch (~6 min). Here are some results:
<img src="./img/correct-classification.png" hspace="20%" width="50%"> <img src="./img/incorrect-classification.png" hspace="20%" width="50%">

Installation

  • Create a virtual environment in the root folder using virtualenv and activate it.
# On Linux terminal, using virtualenv.
virtualenv myenv
# Activate it.
source myenv/bin/activate
  • Install requirements.txt.
pip install -r requirements.txt
# Tidy up the root folder.
python3 setup.py clean

Usage of demo notebooks

To play with the demo-notebooks/ files, you need to make sure jupyter notebook can select your virtual environnment as a kernel.

  • Follow "Installation" instructions first and make sure your virtual environment is still activated.
  • Run the following line in the terminal.
python -m ipykernel install --user--name=myenv
  • Run the notebook file only from demo_notebooks/ and then select Kernel > Switch Kernel > myenv. You are now ready to go !
<!--- Variables with links. -->
View on GitHub
GitHub Stars58
CategoryDevelopment
Updated3mo ago
Forks11

Languages

Python

Security Score

82/100

Audited on Dec 10, 2025

No findings