Skip to content

transmuteAI/implicit-networks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Implicit Equivariance in Convolutional Networks

1. Overview

This repository consists of the official implementation of the paper "Implicit Equivariance in Convolutional Networks". Standard CNNs are inherently equivariant under translations, however they are not equivariant under other transformations such as rotation and change in scale. In our works we induced equivariance implicitly in the different layers of a standard CNN model by optimizing a multi-objective loss function. More details can be found here.

2. Prerequisites

Install prerequisites with:

$ pip install -r requirements.txt

3. Download Datasets

  • Rot-MNIST: It is a variation of the popular MNIST dataset containing handwritten digits. In Rot-MNIST, the digits are rotated by an angle generated uniformly between 0 and 2π radians. Link to this dataset
  • Rot-TIM: It is a variation of the TinyImageNet dataset which is a miniature version of the ImageNet Dataset. In Rot-TIM, images are rotated by an angle generated uniformly between 0 and 2π radians. Link to this dataset
  • R2-TIM: This dataset is the same as Rot-TIM apart from the fact that some images were flipped at random along the horizontal or vertical axis. Link to this dataset

4. Train Model

Edit params dictionary in main.py. Choose parameters from the following options:

Training Settings:

dataset : rot_mnist, rot_tim. For R2-TIM, choose rot_tim dataset and set reflection : True
model : BasicCNN (for Rot-MNIST), Resnet18, VGG (for Rot-TIM & R2-TIM).
reflection : True or False. For learning equivariance under reflections. Default : False
heterogeneous : True or False. For testing equivariance under heterogeneous filter groups. Default : False
mode : R4 or R8. R4 and R8 denote equivariance to 4 and 8 equidistant orientations respectively. Default : R4
save_dir : Specify folder for saving checkpoints. Default : ien_training
training : True or False.

If heterogeneous is set to True:

For R8-4-2-1, Set ratio : [32,8,2,1] and mplc_kernel_size : [8,4,2,1]
For R8-4-2, Set ratio : [8,2,1] and mplc_kernel_size : [8,4,2]
For R4-2-1, Set ratio : [8,2,1] and mplc_kernel_size : [4,2,1]

Adjusting hyper-parameters:

beta_weight : weightage for equivariance loss i.e. extent of equivariance required. For training equivalent Standard CNN i.e. without equivariance loss, Use beta_weight : 0.
tot_epochs : Total Epochs to train. Default : 90
batch_size : Default: 32.
weight_decay_rate : Weight Decay Rate for Adam optimizer. Default : 1e-7.

Hyper-parameters for Cyclic LR:

max_lr : Highest LR for the cycle. Default : 5e-3
low_lr : Lowest LR for the cycle. Default : 1e-5
cyc_size : Number of epochs for one cycle. Default : 70
dec_scale : Factor by which peak LR decreases for next cycle. Default : 1

After adjusting parameters and hyperparameters, just run main.py

usage: python main.py

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages