-
Notifications
You must be signed in to change notification settings - Fork 15
/
config.py
executable file
·69 lines (51 loc) · 3.7 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
import tensorflow as tf
def config(data_path='ubuntu'):
tf.flags.DEFINE_boolean("auto_gpu", False, "Allow detect gpu automatically")
tf.flags.DEFINE_string('train_record_file', './%s/train.char.tfrecords'%(data_path), 'Path expression to training datafiles. ')
tf.flags.DEFINE_string('valid_record_file', './%s/valid.char.tfrecords'%(data_path), 'Path expression to valid datafiles. ')
tf.flags.DEFINE_string('test_record_file', './%s/test.char.tfrecords'%(data_path), 'Path expression to test datafiles. ')
tf.flags.DEFINE_integer("num_threads", 4, "Thread of parsing data")
tf.flags.DEFINE_integer("capacity", 15000, "Capacity of parsing data")
tf.flags.DEFINE_integer("embed_dim", 200, "Dimensionality of embedding")
tf.flags.DEFINE_integer("rnn_dim", 200, "Dimensionality of rnn")
tf.flags.DEFINE_boolean("init_dict", True, "Allow initialize word2vec")
tf.flags.DEFINE_string('init_embeddings_path', './%s/word_emb_matrix.pkl'%(data_path), 'Path expression to initial embedding file. ')
tf.flags.DEFINE_string('word_dict_path', './%s/word_dict.pkl'%(data_path), 'Path expression to word dict. ')
tf.flags.DEFINE_boolean("init_char_dict", True, "Allow initialize char2vec")
tf.flags.DEFINE_string('init_char_embeddings_path', './%s/char_emb_matrix.pkl'%(data_path), 'Path expression to initial char embedding file. ')
tf.flags.DEFINE_string('char_dict_path', './%s/char_dict.pkl'%(data_path), 'Path expression to char dict. ')
tf.flags.DEFINE_integer("char_vocab_size", 173, "Size of char vocabulary")
tf.flags.DEFINE_integer("char_embed_dim", 64, "Dimensionality of char embedding")
tf.flags.DEFINE_integer("char_hid", 100, "Dimensionality of char embedding") # 100
tf.flags.DEFINE_integer("vocab_size", 439759, "Size of vocabulary")
tf.flags.DEFINE_integer("max_turn", 10, "Max length of turn")
tf.flags.DEFINE_integer("max_utterance_len", 50, "Max length of word")
tf.flags.DEFINE_integer("max_word_len", 16, "Max length of characters")
tf.flags.DEFINE_boolean("use_char", True, "Allow use char rep")
tf.flags.DEFINE_boolean("use_word", True, "Allow use word rep")
tf.flags.DEFINE_boolean("use_seq", True, "Allow use seq rep")
tf.flags.DEFINE_boolean("use_conv", True, "Allow use conv rep")
tf.flags.DEFINE_boolean("use_self", True, "Allow use self rep")
tf.flags.DEFINE_boolean("use_cross", True, "Allow use cross rep")
tf.flags.DEFINE_float("dropout_keep_prob", 0.8, "Dropout keep probability")
tf.flags.DEFINE_float('lr', 1e-3, 'Initial learning rate') # 0.15
tf.flags.DEFINE_boolean("lr_decay", False, "Allow use decay for learning rate")
tf.flags.DEFINE_float('decay_rate', 0.9, 'decay rate')
tf.flags.DEFINE_integer('decay_steps', 2000, 'decay steps')
tf.flags.DEFINE_float('lr_minimal', 0.00005, 'minimal learning rate') # 0.00002
# Training parameters
tf.flags.DEFINE_integer("batch_size", 100, "Batch Size")
tf.flags.DEFINE_integer("num_epochs", 80000, "Number of training epochs")
tf.flags.DEFINE_integer("print_every", 50, "Print the results after this many steps")
tf.flags.DEFINE_integer("valid_every", 1000, "Valid model on dev set after this many steps")
tf.flags.DEFINE_integer("checkpoint_every", 4000, "Save model after this many step")
tf.flags.DEFINE_integer("test_every", 1000, "Testing model after this many step")
tf.flags.DEFINE_boolean("reload_model", False, "Allow reload the model")
tf.flags.DEFINE_string('log_root', 'logs_tmp/', 'Root directory for all logging.')
# Misc Parameters
tf.flags.DEFINE_string('gpu', 'gpu:0', 'Which GPU to use')
tf.flags.DEFINE_boolean("allow_soft_placement", True, "Allow device soft device placement")
tf.flags.DEFINE_boolean("log_device_placement", False, "Log placement of ops on devices")
FLAGS = tf.flags.FLAGS
FLAGS._parse_flags()
return FLAGS