项目作者: 3outeille

项目描述 :
A Numpy implementation of a Convolutional Neural Network: slow & fast (im2col/col2im).
高级语言: Python
项目地址: git://github.com/3outeille/CNNumpy.git
创建时间: 2019-12-05T13:22:30Z
项目社区:https://github.com/3outeille/CNNumpy

开源协议:

下载


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 (@machine-learning/blog-post-cnnumpy-slow">slow and @machine-learning/blog-post-cnnumpy-fast">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:


Installation

  • Create a virtual environment in the root folder using virtualenv and activate it.
  1. # On Linux terminal, using virtualenv.
  2. virtualenv myenv
  3. # Activate it.
  4. source myenv/bin/activate
  • Install requirements.txt.
  1. pip install -r requirements.txt
  2. # Tidy up the root folder.
  3. 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.
    1. 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 !