Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/3outeille/cnnumpy
A Numpy implementation of a Convolutional Neural Network: slow & fast (im2col/col2im).
https://github.com/3outeille/cnnumpy
cnn col2im convolutional-neural-networks im2col numpy python python3
Last synced: 25 days ago
JSON representation
A Numpy implementation of a Convolutional Neural Network: slow & fast (im2col/col2im).
- Host: GitHub
- URL: https://github.com/3outeille/cnnumpy
- Owner: 3outeille
- Created: 2019-12-05T13:22:30.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-06T22:00:25.000Z (over 1 year ago)
- Last Synced: 2023-10-20T15:46:36.254Z (about 1 year ago)
- Topics: cnn, col2im, convolutional-neural-networks, im2col, numpy, python, python3
- Language: Python
- Homepage: https://3outeille.github.io/deep-learning/
- Size: 32.8 MB
- Stars: 43
- Watchers: 3
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## 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][slow-implementation] takes around **4 hours for 1 epoch** where the [fast implementation][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][slow-blog] and [fast][fast-blog]).**
- In the [`demo-cnnumpy-fast.ipynb`][demo-notebook] notebook, the im2col/col2im implementation can achieve an accuracy up to **97.2% in 1 epoch (~6 min)**. Here are some results:
## Installation
- Create a virtual environment in the root folder using [virtualenv][virtualenv] and activate it.
```bash
# On Linux terminal, using virtualenv.
virtualenv myenv
# Activate it.
source myenv/bin/activate
```- Install **requirements.txt**.
```bash
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.
```bash
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 ![slow-implementation]: https://github.com/3outeille/CNNumpy/tree/master/src/slow
[fast-implementation]: https://github.com/3outeille/CNNumpy/tree/master/src/fast
[slow-blog]: https://hackmd.io/@machine-learning/blog-post-cnnumpy-slow
[fast-blog]: https://hackmd.io/@machine-learning/blog-post-cnnumpy-fast
[demo-notebook]: https://github.com/3outeille/CNNumpy/blob/master/src/demo_notebooks/demo-cnnumpy-fast.ipynb
[virtualenv]: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/