forked from lv-jiajun/S2FVD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParameterConfig.py
More file actions
72 lines (60 loc) · 2.8 KB
/
Copy pathParameterConfig.py
File metadata and controls
72 lines (60 loc) · 2.8 KB
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
import numpy as np
class ParameterConfig(object):
"""
Some Configurations
"""
# 设置一些参数
# GNN Parameters
# GCN_HIDDEN_DIM = 128 # hidden dimension of node state
GCN_HIDDEN_DIM = 192 # hidden dimension of node state
GCN_Layer_Num = 1 # the number of hidden layers
GCN_DP_RATE = 0.
# GAT
# GAT_HIDDEN_DIM = 128 # hidden dimension of node state
GAT_HIDDEN_DIM = 192 # hidden dimension of node state
HEAD_NUM = 5
GAT_Layer_Num = 1
GAT_FEAT_DP_RATE = 0.
GAT_ATT_DP_RATE = 0.
# General
device = None
EMBEDDING_DIM = 100 # dimension of pre-trained word vector
MAX_SEQUENCE_LENGTH = 20 # max length of a sentence (basic block)
EPOCHES = 100 # 设置轮数
BATCH_SIZE = 128 # 最好是2的倍数
dataset_split_ratio = 0.2
OCCUPY_ALL = False # occupy all GPU or not
PRINT_PER_BATCH = 100 # print result every xxx batches
PRE_TRAINING = True # use vectors trained by word2vec or not
SEED = np.random.seed()
lr = 1e-3 # learning rate
lr_decay = 0.9 # learning rate decay
# lr_decay = 0.1 # learning rate decay
clip = 1.0 # gradient clipping threshold
l2_reg_lambda = 0.01 # l2 regularization lambda
# TextCNN-related
NUM_FILTERS = 128 # number of convolution kernel
FILTER_SIZES = [2, 3, 4] # size of convolution kernel
DROP_OUT = 0.5 # drop out rate
# other parameters
CFG_MIN_EDGE_NUM = 1
PIN_MEM = False
NUM_WORKERS = 4
def log_config(prefix):
with open(prefix + '#config', 'w') as f:
f.write('EMBEDDING_DIM =' + str(ParameterConfig.EMBEDDING_DIM) + '\n')
f.write('MAX_SEQUENCE_LENGTH=' + str(ParameterConfig.MAX_SEQUENCE_LENGTH) + '\n')
f.write('GCN_HIDDEN_DIM='+str(ParameterConfig.GCN_HIDDEN_DIM) + '\n')
f.write('GAT_HIDDEN_DIM='+str(ParameterConfig.GAT_HIDDEN_DIM) + '\n')
f.write('HEAD_NUM='+str(ParameterConfig.HEAD_NUM) + '\n')
f.write('CFG_MIN_EDGE_NUM='+str(ParameterConfig.CFG_MIN_EDGE_NUM) + '\n')
f.write('NUM_FILTERS=' + str(ParameterConfig.NUM_FILTERS) + '\n')
f.write('FILTER_SIZES=' + str(ParameterConfig.FILTER_SIZES) + '\n')
f.write('DROP_OUT=' + str(ParameterConfig.DROP_OUT) + '\n')
f.write('BATCH_SIZE=' + str(ParameterConfig.BATCH_SIZE) + '\n')
f.write('EPOCHES=' + str(ParameterConfig.EPOCHES) + '\n')
f.write('LEARNING_RATE=' + str(ParameterConfig.lr) + '\n')
f.write('DATASET_SPLIT_RATIO=' + str(ParameterConfig.dataset_split_ratio) + '\n')
f.write('HIDDEN_DIM=' + str(ParameterConfig.HEAD_NUM) + '\n')
f.write('HEAD_NUM=' + str(ParameterConfig.HEAD_NUM) + '\n')
f.close()