-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathconfig.py
74 lines (60 loc) · 2.17 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'''This file configures the training procedure because handling arguments in every single function is so exhaustive for
research purposes. Don't try this code if you are a software engineer.'''
import torch
# device settings
#'cuda' or 'cpu'
device = 'cpu'
if device == 'cuda':
torch.cuda.set_device(0)
# neptune
neptune_activate = False
# data settings
dataset_path = "dummy_dataset"
class_name = "dummy_class"
modelname = "dummy_test"
# transformation settings
transf_rotations = True
transf_brightness = 0.0
transf_contrast = 0.0
transf_saturation = 0.0
norm_mean, norm_std = [0.485, 0.456, 0.406], [0.229, 0.224, 0.225]
# feature extractor
# select "resnet18", "deit", or "cait"
extractor_name = "deit"
# network hyperparameters
n_scales = 1 # number of scales at which features are extracted, img_size is the highest - others are //2, //4,...
clamp_alpha = 3 # see paper (differnet) equation 2 for explanation
clamp = 1.2 # clamp in convolutional layers
n_coupling_blocks = 4
#fc_internal = 2048 # number of neurons in hidden layers of s-t-networks
dropout = 0.0 # dropout in s-t-networks
lr_init = 2e-4
subnet_conv_dim = 128 # internal dimension of the convolutional layera
only_3x3_convolution = False # set all convolutional layers to have 3x3 convolutions
if(extractor_name == "resnet18"):
n_feat = 64*64*64*n_scales
img_size = (256, 256)
elif(extractor_name == "deit"):
n_feat = 24*24*768*n_scales
img_size = (384, 384)
elif(extractor_name == "cait"):
n_feat = 28*28*768*n_scales
img_size = (448, 448)
else:
n_feat = 256 * n_scales # do not change except you change the feature extractor
img_size = (448, 448)
img_dims = [3] + list(img_size)
# dataloader parameters
n_transforms = 4 # number of transformations per sample in training
n_transforms_test = 64 # number of transformations per sample in testing
batch_size = 24 # actual batch size is this value multiplied by n_transforms(_test)
batch_size_test = batch_size * n_transforms // n_transforms_test
# total epochs = meta_epochs * sub_epochs
# evaluation after <sub_epochs> epochs
meta_epochs = 24
sub_epochs = 8
# output settings
verbose = True
grad_map_viz = False
hide_tqdm_bar = False
save_model = True