-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigurations.py
41 lines (36 loc) · 1.24 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
import os
import git
def generate_config(dataset, args, exp_name):
repo = git.Repo(search_parent_directories=True)
config = {
'model': {
'encoder': {
'type': args.encoder,
},
'decoder': {
'attention': {
'type': 'tanh'
},
'output_size': dataset.output_size
}
},
'training': {
'bsize': args.bsize,
'weight_decay': args.weight_decay,
'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'})
if args.encoder != 'bert':
config['model']['encoder'].update({'vocab_size': dataset.vocab_size,
'embed_size': dataset.word_dim,
'hidden_size': args.hidden_size,})
return config