forked from dasguptar/treelstm.pytorch
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
62 lines (52 loc) · 3.28 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
import argparse
def parse_args():
parser = argparse.ArgumentParser(description='PyTorch TreeLSTM for Sentence Similarity on Dependency Trees')
parser.add_argument('--data', default='data/sick/',
help='path to dataset')
parser.add_argument('--glove', default='/data/tmp/glove/',
help='directory with GLOVE embeddings')
parser.add_argument('--encoder_type', default="TreeLSTM", choices=["TreeLSTM", "LSTM"],
help='model type to use as sentence encoder')
parser.add_argument('--batchsize', default=25, type=int,
help='batchsize for optimizer updates')
parser.add_argument('--epochs', default=30, type=int,
help='number of total epochs to run')
parser.add_argument('--lr', default=1e-3, type=float,
metavar='LR', help='initial learning rate')
parser.add_argument('--wd', default=0, type=float,
help="weight decay (original paper's default: 1e-4)")
parser.add_argument('--dropout_prob', default=0, type=float,
help='dropout probability')
# Recurrent Highway Networks
parser.add_argument('--rhn_type', default=None, choices=[None, "gated", 'residual'],
help='Type of connections to use for RHN architecture (if any)')
parser.add_argument('--h_rhn_depth', default=0, type=int,
help='number of additional steps in recurrent highway network for h')
parser.add_argument('--h_rhn_gate_bias', default=2, type=int,
help='Initial bias for gate in RHN. 2 = start almoust without usage of RHN')
parser.add_argument('--c_rhn_depth', default=0, type=int,
help='number of additional steps in recurrent highway network for c')
parser.add_argument('--c_rhn_gate_bias', default=2, type=int,
help='Initial bias for gate in RHN. 2 = start almoust without usage of RHN')
# dimensions
parser.add_argument('--input_dim', type=int, default=300, help="embedding's dimension")
parser.add_argument('--mem_dim', type=int, default=150, help="LSTM's hidden state (and cell memory) dimension")
parser.add_argument('--hidden_dim', type=int, default=50, help="'Similarity' FC network hidden state dimension")
parser.add_argument('--num_classes', type=int, default=5, help="Number of predicted classes")
parser.add_argument('--cell_m', action='store_true', default=False,
help='use cell memory as sentence embedding instead of hidden state')
parser.add_argument('--output_gate', action='store_true', default=True,
help="use LSTM's output gate if True")
parser.add_argument('--sparse', action='store_true',
help='Enable sparsity for embeddings, \
incompatible with weight decay')
parser.add_argument('--optim', default='adam',
help='optimizer (default: adagrad)')
parser.add_argument('--seed', default=123, type=int,
help='random seed (default: 123)')
cuda_parser = parser.add_mutually_exclusive_group(required=False)
cuda_parser.add_argument('--cuda', dest='cuda', action='store_true')
cuda_parser.add_argument('--no-cuda', dest='cuda', action='store_false')
parser.set_defaults(cuda=False)
args = parser.parse_args()
return args