-
Notifications
You must be signed in to change notification settings - Fork 6
/
configurations.py
48 lines (41 loc) · 1.4 KB
/
configurations.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
import os
import git
def generate_config(dataset, args, exp_name) :
repo = git.Repo(search_parent_directories=True)
if args.encoder == 'lstm' :
enc_type = 'rnn'
elif args.encoder == 'average' :
enc_type = args.encoder
else :
raise Exception("unknown encoder type")
config = {
'model' :{
'encoder' : {
'vocab_size' : dataset.vec.vocab_size,
'embed_size' : dataset.vec.word_dim,
'type' : enc_type,
'hidden_size' : args.hidden_size
},
'decoder' : {
'attention' : {
'type' : 'tanh'
},
'output_size' : dataset.output_size
}
},
'training' : {
'bsize' : dataset.bsize if hasattr(dataset, 'bsize') else 32,
'weight_decay' : 1e-5,
'pos_weight' : dataset.pos_weight if hasattr(dataset, 'pos_weight') else None,
'basepath' : dataset.basepath if hasattr(dataset, 'basepath') else 'outputs',
'exp_dirname' : os.path.join(dataset.name, exp_name)
},
'git_info' : {
'branch' : repo.active_branch.name,
'sha' : repo.head.object.hexsha
},
'command' : args.command
}
if args.encoder == 'average' :
config['model']['encoder'].update({'projection' : True, 'activation' : 'tanh'})
return config