Giter Site home page Giter Site logo

cjones6 / yesweckn Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 42.68 MB

Implementation of Convolutional Kernel Networks for the paper "Kernel-based Translations of Convolutional Networks"

License: GNU General Public License v3.0

Python 62.63% Shell 12.66% Jupyter Notebook 24.72%

yesweckn's Introduction

YesWeCKN

This code provides an implementation of convolutional kernel networks trained using the method developed in the following paper:

C. Jones, V. Roulet and Z. Harchaoui. Kernel-based Translations of Convolutional Networks. arXiv preprint arXiv:1903.08131, 2019.

If you use this code please cite the paper using the bibtex reference below.

@article{JRH2019,
  title={Kernel-based Translations of Convolutional Networks},
  author={Jones, Corinne and Roulet, Vincent and Harchaoui, Zaid},
  journal={arXiv preprint arXiv:1903.08131},
  year={2019}
}

Introduction

Convolutional kernel networks, first introduced by Mairal et al. (2014) and further developed by Mairal (2016) and Paulin et al. (2017), allow one to learn feature representations for images or signals in an unsupervised or in a supervised manner. In our paper we describe a systematic way to transform a ConvNet into a CKN. Moreover, we develop an end-to-end training algorithm for CKNs and demonstrate that CKNs can often achieve comparable performance to their ConvNet counterparts.

This code implements CKNs for images and other data observed on a grid and trains them using a stochastic gradient optimization method with an accurate gradient. The scripts in the experiments folder train the CKN counterparts to LeNet-1 and LeNet-5 on MNIST (LeCun et al., 1998), All-CNN-C on CIFAR-10 (Springenberg et al., 2015; Krizhevsky and Hinton, 2009), and AlexNet on a subset of ImageNet (Krizhevsky et al., 2012; Krizhevsky 2014). Each architecture is specified in the cfg folder.

Installation

This code is compatible with Python 3.7 and was originally written with PyTorch version 1.2.0.

The primary original dependencies are:

The following terminal commands create a new Anaconda environment called ckn and install newer versions of the above packages, assuming you have a GPU and Cuda 10.0:

conda create -y --name=ckn python=3.7
conda activate ckn
conda install jupyter matplotlib nb_conda numpy scipy 
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
conda install faiss-gpu cudatoolkit=10.0 -c pytorch

If you wish to run the code on a GPU with a different version of Cuda, see the PyTorch and Faiss documentations. If you only have a CPU you should change the last two lines above to

conda install pytorch torchvision cpuonly -c pytorch
conda install faiss-cpu -c pytorch

The code can run on a CPU or GPU, although it is intended to be run on a GPU. It is currently set to run on a GPU. To run it on a CPU change the line device = torch.device('cuda:0') in the file src/default_params.py to device = torch.device('cpu')

This version of the code is not compatible with older versions of PyTorch. The code has only been tested on Linux operating systems.

Running the code

The scripts to reproduce the experiments are in the experiments folder. You will need to provide the path to the data folder as the argument data_path. There is a Google Colab notebook that you can try out here, which corresponds to the Jupyter notebook found at example/mnist_lenet-5_ckn_convnet_example.ipynb. There is also an interactive visualization of the filters of the trained CKNs and ConvNets that you can explore here!

Contact

You can report issues and ask questions in the repository's issues page. If you choose to send an email instead, please direct it to Corinne Jones at [email protected] and include [yesweckn] in the subject line.

Authors

Corinne Jones
Vincent Roulet
Zaid Harchaoui

License

This code has a GPLv3 license.

Acknowledgements

This work was supported by NSF TRIPODS Award CCF-1740551, the program "Learning in Machines and Brains" of CIFAR, and faculty research awards.

yesweckn's People

Contributors

cjones6 avatar vroulet avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.