config.py 1.2 KB
Newer Older
P
peterzhang2029 已提交
1 2 3 4 5
__all__ = ["TrainerConfig", "ModelConfig"]


class TrainerConfig(object):

P
peterzhang2029 已提交
6
    # Whether to use GPU in training or not.
P
peterzhang2029 已提交
7
    use_gpu = False
P
peterzhang2029 已提交
8
    # The number of computing threads.
P
peterzhang2029 已提交
9 10
    trainer_count = 1

P
peterzhang2029 已提交
11
    # The training batch size.
P
peterzhang2029 已提交
12 13
    batch_size = 32

P
peterzhang2029 已提交
14
    # The epoch number.
P
peterzhang2029 已提交
15 16
    num_passes = 10

P
peterzhang2029 已提交
17
    # The global learning rate.
P
peterzhang2029 已提交
18 19
    learning_rate = 1e-3

P
peterzhang2029 已提交
20
    # The decay rate for L2Regularization
P
peterzhang2029 已提交
21 22
    l2_learning_rate = 1e-3

P
peterzhang2029 已提交
23 24 25 26 27 28
    # This parameter is used for the averaged SGD.
    # About the average_window * (number of the processed batch) parameters
    # are used for average.
    # To be accurate, between average_window *(number of the processed batch)
    # and 2 * average_window * (number of the processed batch) parameters
    # are used for average.
P
peterzhang2029 已提交
29 30
    average_window = 0.5

P
peterzhang2029 已提交
31 32
    # The buffer size of the data reader.
    # The number of buffer size samples will be shuffled in training.
P
peterzhang2029 已提交
33 34
    buf_size = 1000

P
peterzhang2029 已提交
35 36
    # The parameter is used to control logging period.
    # Training log will be printed every log_period.
P
peterzhang2029 已提交
37 38 39 40 41
    log_period = 100


class ModelConfig(object):

P
peterzhang2029 已提交
42
    # The dimension of embedding vector.
P
peterzhang2029 已提交
43 44
    emb_size = 28

P
peterzhang2029 已提交
45
    # The hidden size of sentence vectors.
P
peterzhang2029 已提交
46
    hidden_size = 128