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.
Install prerequisites with:
$ pip install -r requirements.txt
- 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
Edit params dictionary in main.py
. Choose parameters from the following options:
Training Settings:
dataset
:rot_mnist
,rot_tim
. For R2-TIM, chooserot_tim
dataset and setreflection : True
model
:BasicCNN
(for Rot-MNIST),Resnet18
,VGG
(for Rot-TIM & R2-TIM).
reflection
:True
orFalse
. For learning equivariance under reflections.Default : False
heterogeneous
:True
orFalse
. For testing equivariance under heterogeneous filter groups.Default : False
mode
:R4
orR8
. 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
orFalse
.
If heterogeneous
is set to True
:
For R8-4-2-1, Set
ratio : [32,8,2,1]
andmplc_kernel_size : [8,4,2,1]
For R8-4-2, Setratio : [8,2,1]
andmplc_kernel_size : [8,4,2]
For R4-2-1, Setratio : [8,2,1]
andmplc_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, Usebeta_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
This project is licensed under the MIT License.