-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_config.py
74 lines (61 loc) · 3.71 KB
/
train_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
import argparse
import os
import logging
from config import log_config, dir_config
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def parse_args():
parser = argparse.ArgumentParser(description='command for train on CUHK-PEDES')
# Directory
parser.add_argument('--image_dir', type=str, help='directory to store dataset')
parser.add_argument('--anno_dir', type=str, help='directory to store anno file')
parser.add_argument('--checkpoint_dir', type=str, help='directory to store checkpoint')
parser.add_argument('--log_dir', type=str, help='directory to store log')
parser.add_argument('--model_path', type=str, default = None, help='directory to pretrained model, whole model or just visual part')
# LSTM setting
parser.add_argument('--embedding_size', type=int, default=768)
parser.add_argument('--num_lstm_units', type=int, default=512)
parser.add_argument('--vocab_size', type=int, default=4092)
parser.add_argument('--lstm_dropout_ratio', type=float, default=0.7)
parser.add_argument('--max_length', type=int, default=100)
parser.add_argument('--bidirectional', action='store_true')
parser.add_argument('--embedding_init_path', type=str, default= "")
# Model setting
parser.add_argument('--image_model', type=str, default='mobilenet_v1')
parser.add_argument('--resume', action='store_true', help='whether or not to restore the pretrained whole model')
parser.add_argument('--da', action='store_true', help='whether or not da')
parser.add_argument('--batch_size', type=int, default=16)
parser.add_argument('--num_epoches', type=int, default=100)
parser.add_argument('--ckpt_steps', type=int, default=5000, help='#steps to save checkpoint')
parser.add_argument('--feature_size', type=int, default=512)
parser.add_argument('--img_model', type=str, default='mobilenet_v1', help='model to train images')
parser.add_argument('--loss_weight', type=float, default=1)
parser.add_argument('--CMPM', action='store_true')
parser.add_argument('--CMPC', action='store_true')
parser.add_argument('--cnn_dropout_keep', type=float, default=0.999)
parser.add_argument('--constraints_text', action='store_true')
parser.add_argument('--constraints_images', action='store_true')
parser.add_argument('--num_classes', type=int, default=11003)
parser.add_argument('--pretrained', action='store_true', help='whether or not to restore the pretrained visual model')
# Optimization setting
parser.add_argument('--optimizer', type=str, default='adam', help='one of "sgd", "adam", "rmsprop", "adadelta", or "adagrad"')
parser.add_argument('--lr', type=float, default=0.0002)
parser.add_argument('--wd', type=float, default=0.00004)
parser.add_argument('--adam_alpha', type=float, default=0.9)
parser.add_argument('--adam_beta', type=float, default=0.999)
parser.add_argument('--epsilon', type=float, default=1e-8)
parser.add_argument('--end_lr', type=float, default=0.0001, help='minimum end learning rate used by a polynomial decay learning rate')
parser.add_argument('--lr_decay_type', type=str, default='exponential', help='One of "fixed" or "exponential"')
parser.add_argument('--lr_decay_ratio', type=float, default=0.1)
parser.add_argument('--epoches_decay', type=str, default='50,100', help='#epoches when learning rate decays')
parser.add_argument('--nsave', type=str, default='')
# Default setting
parser.add_argument('--gpus', type=str, default='0')
parser.add_argument('--pseudo_labels', action='store_true', help='whether or not use pseudo_labels')
args = parser.parse_args()
return args
def config():
args = parse_args()
dir_config(args)
log_config(args,'train')
return args