-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
executable file
·163 lines (116 loc) · 5.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# config.py ---
#
# Filename: config.py
# Description:
# Modified by Author: Kwang Moo Yi
# Copyright (C), Visual Computing Group @ University of Victoria.
# Code:
import argparse
# ----------------------------------------
# Global variables within this script
arg_lists = []
parser = argparse.ArgumentParser()
# ----------------------------------------
# Some nice macros to be used for arparse
def str2bool(v):
return v.lower() in ("true", "1")
def add_argument_group(name):
arg = parser.add_argument_group(name)
arg_lists.append(arg)
return arg
# ----------------------------------------
# Arguments for the main program
main_arg = add_argument_group("Main")
main_arg.add_argument("--mode", type=str,
default="train",
choices=["train", "test"],
help="Run mode")
# ----------------------------------------`
# Arguments for training
train_arg = add_argument_group("Training")
train_arg.add_argument("--img_dir", type=str,
default="/home/ubuntu/users/tongpinmo/dataset/kaggle_Fashion_FCVC6/train/",
help="Directory with train dataset")
train_arg.add_argument("--ann_path", type=str,
default="/home/ubuntu/users/tongpinmo/dataset/kaggle_Fashion_FCVC6/train.csv",
help="Directory with train dataset")
train_arg.add_argument("--test_dir", type=str,
default="/home/ubuntu/users/tongpinmo/dataset/kaggle_Fashion_FCVC6/test/",
help="Directory with test dataset")
train_arg.add_argument('--sample_path', type=str,
default= '/home/ubuntu/users/tongpinmo/dataset/kaggle_Fashion_FCVC6/sample_submission.csv',
help = 'Directory with test dataset')
train_arg.add_argument('--submit_path', type=str,
default= '/home/ubuntu/users/tongpinmo/projects/kaggle-imaterialist/',
help = 'Directory with submit')
train_arg.add_argument('--width',type = int,
default = 512,
help = 'resize width for the data')
train_arg.add_argument('--height',type = int,
default = 512,
help = 'resize height for the data')
train_arg.add_argument("--seed",type=int,
default=0,
help="fix the seed for torch")
train_arg.add_argument("--batch_size", type=int,
default= 2,
help="Size of each training batch")
train_arg.add_argument("--num_epochs", type=int,
default=10,
help="Number of epochs to train")
train_arg.add_argument("--epoch_cb", type=int,
default=100,
help="Number of epochs by which a callback is excuted")
train_arg.add_argument("--rep_intv", type=int,
default=10,
help="Report interval")
train_arg.add_argument("--val_intv", type=int,
default=10,
help="Validation interval")
train_arg.add_argument("--log_dir", type=str,
default="./logs",
help="Directory to save logs and current model")
train_arg.add_argument("--save_dir", type=str,
default="./save",
help="Directory to save the best model")
train_arg.add_argument("--out_dir", type=str,
default="./out",
help="Directory to save the output of vae models")
train_arg.add_argument("--resume", type=str2bool,
default=True,
help="Whether to resume training from existing checkpoint")
#--------------------------------------------------------------
# ----------------------------------------
# Arguments for model
model_arg = add_argument_group("Model")
model_arg.add_argument("--normalize", type=str2bool,
default=True,
help="Whether to normalize with mean/std or not")
model_arg.add_argument("--l2_reg", type=float,
default=0.0002,
help="L2 Regularization strength")
model_arg.add_argument("--ksize", type=int,
default=3,
help="Size of the convolution kernel")
model_arg.add_argument("--num_filters",type=int,
default=32,
help="Default number of filters")
model_arg.add_argument("--zdim",type=int,
default=256,
help = "dimension of the latent representation z")
model_arg.add_argument("--num_conv_outer",type=int,
default=5,
help = "Number of outer blocks (steps)")
model_arg.add_argument("--vy",type=float,
default=0.002,
help="conditional norm lik variance")
model_arg.add_argument("--act", type=str,
default="elu",
help="Activation type")
def get_config():
config, unparsed = parser.parse_known_args()
return config, unparsed
def print_usage():
parser.print_usage()
#
# config.py ends here