You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the official code for CoLLAs 2022 paper, "InBiaseD: Inductive Bias Distillation to Improve Generalization and Robustness through Shape-awareness" by Shruthi Gowda, Elahe Arani and Bahram Zonooz.
4
+
5
+
## Requirements
6
+
- python==3.8.0
7
+
- torch==1.10.0
8
+
- torchvision==0.8.0
9
+
10
+
## Methodology
11
+
```
12
+
Network : Resnet18
13
+
```
14
+
####InBiaseD framework
15
+
16
+
There are 2 networks:
17
+
InBiaseD-network receiving RGB images and
18
+
Shape-network receiving shape images. InBiaseD is used for inference.
19
+
20
+

21
+
22
+
## Datasets and Setup
23
+
24
+

25
+
26
+
The learning rate is set to $0.1$ (except for C-MNIST where it is $0.01$). SGD optimizer is used with a momentum of 0.9 and a weight decay of 1e-4. The same settings as for baselines are used for training InBiaseD. We apply random crop and random horizontal flip as the augmentations for all training.
27
+
Resnet-18* refers to the CIFAR-version in which the first convolutional layer has 3x3 kernel and the maxpool operation is removed.
28
+
29
+

30
+
31
+
## Running
32
+
33
+
####Train Baseline
34
+
35
+
```
36
+
python train_normal.py
37
+
--exp_identifier train_tinyimagenet_baseline
38
+
--model_architecture ResNet18
39
+
--dataset tinyimagenet
40
+
--data_path <path to tinyimagenet dataset>
41
+
--lr 0.1
42
+
--weight_decay 0.0005
43
+
--batch_size 128
44
+
--epochs 250
45
+
--cuda
46
+
--test_eval_freq 100
47
+
--train_eval_freq 100
48
+
--seeds 0 10 20
49
+
--ft_prior std
50
+
--scheduler cosine
51
+
--output_dir /tinyimagenet_baseline
52
+
```
53
+
####Train InBiaseD
54
+
55
+
```
56
+
python train_inbiased.py
57
+
--exp_identifier train_tinyimagenet_inbiased
58
+
--model1_architecture ResNet18
59
+
--model2_architecture ResNet18
60
+
--dataset tinyimagenet
61
+
--data_path <path to tinyimagenet dataset>
62
+
--lr 0.1
63
+
--weight_decay 0.0005
64
+
--batch_size 128
65
+
--epochs 250
66
+
--cuda
67
+
--test_eval_freq 100
68
+
--train_eval_freq 100
69
+
--seeds 0 10 20
70
+
--ft_prior sobel
71
+
--loss_type kl fitnet
72
+
--loss_wt_kl1 1
73
+
--loss_wt_kl2 1
74
+
--loss_wt_at1 1
75
+
--loss_wt_at2 5
76
+
--scheduler cosine
77
+
--output_dir /tinyimagenet_inbiased
78
+
```
79
+
80
+
###Test
81
+
####For evaluation only one network is used - the InBiaseD network (the first network)
82
+
```
83
+
python test.py
84
+
--dataset
85
+
tinyimagenet
86
+
--data_path
87
+
<path to tinyimagenet dataset>
88
+
--model_path
89
+
/tinyimagenet_inbiased/final_model1.pth
90
+
--cuda
91
+
--output_dir
92
+
/tinyimagenet_inbiased/results_inbiased
93
+
```
94
+
95
+
####For results of shapeNet (second network)
96
+
```
97
+
python test.py
98
+
--dataset
99
+
tinyimagenet
100
+
--data_path
101
+
<path to tinyimagenet dataset>
102
+
--model_path
103
+
/tinyimagenet_inbiased/final_model2.pth
104
+
--cuda
105
+
--output_dir
106
+
/tinyimagenet_inbiased/results_shapenet
107
+
```
108
+
109
+
####For Ensemble of InBiaseD Networks:
110
+
111
+
For evaluation only one network is used - the InBiaseD network (the first network)
112
+
```
113
+
python ensemble.py
114
+
--dataset
115
+
tinyimagenet
116
+
--data_path
117
+
<path to tinyimagenet dataset>
118
+
--model_path1
119
+
/tinyimagenet_inbiased/final_model1.pth
120
+
--model_path2
121
+
/tinyimagenet_inbiased/final_model2.pth
122
+
--cuda
123
+
--output_dir
124
+
/tinyimagenet_inbiased/results_ensemble
125
+
```
126
+
127
+
##Cite Our Work
128
+
129
+
## License
130
+
131
+
This project is licensed under the terms of the MIT license.
0 commit comments