-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_generate_parameter_variations.py
executable file
·81 lines (56 loc) · 3.08 KB
/
main_generate_parameter_variations.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python3
import argparse
import numpy as np
import os.path
from os.path import join
import pickle as pkl
import config
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='generate variations to a config')
parser.add_argument('-s', dest='std', type=float, default=.1, help='standard deviation around base config values')
parser.add_argument('-N', dest='variations', type=int, default=100, help='number of parameter variations to generate (default: 100)')
parser.add_argument('-c', dest='configname', type=str, default='final_config', help='base config name')
args = parser.parse_args()
std = args.std
num_vars = args.variations
configname = args.configname
op = 'run'
# get content space and config data
config_c, config_v, variant, recall_cfg = config.load(configname)
if op == 'run':
for n in range(num_vars):
config_c0 = config_c.copy()
config_v0 = config_v.copy()
# change values
for k, v in config_c0.items():
if k[:6] == 'alpha_':
continue
config_c0[k] = np.random.normal(v, std*v)
for k, v in config_v0.items():
if k[:6] == 'alpha_':
continue
config_v0[k] = np.random.normal(v, std*v)
# check variables so they make sense
# time constants must be positive
config_c0['tau_minus'] = max(config_c0['tau_minus'], 0.1)
config_c0['tau_plus_SE'] = max(config_c0['tau_plus_SE'], 0.1)
config_v0['tau_minus'] = max(config_v0['tau_minus'], 0.1)
config_v0['tau_plus_SE'] = max(config_v0['tau_plus_SE'], 0.1)
config_v0['tau_plus_EE'] = max(config_v0['tau_plus_EE'], 0.1)
# excitatory weights must be positive
config_c0['w_SE_low'] = max(config_c0['w_SE_low'], 0)
config_c0['w_SE_high'] = max(config_c0['w_SE_high'], .01)
config_v0['w_SE_low'] = max(config_v0['w_SE_low'], 0)
config_v0['w_SE_high'] = max(config_v0['w_SE_high'], .01)
config_v0['w_EE_low'] = max(config_v0['w_EE_low'], 0)
config_v0['w_EE_high'] = max(config_v0['w_EE_high'], .01)
# low weight must be smaller than high weight for weight init
config_c0['w_SE_high'] = max(config_c0['w_SE_low']*1.01, config_c0['w_SE_high']) # low < high
config_c0['w_SE_max'] = max(config_c0['w_SE_high'], config_c0['w_SE_max'])
config_v0['w_SE_high'] = max(config_v0['w_SE_low']*1.01, config_v0['w_SE_high']) # low < high
config_v0['w_SE_max'] = max(config_v0['w_SE_high'], config_v0['w_SE_max'])
config_v0['w_EE_high'] = max(config_v0['w_EE_low']*1.01, config_v0['w_EE_high']) # low < high
config_v0['w_EE_max'] = max(config_v0['w_EE_high'], config_v0['w_EE_max'])
# write config
configname0 = configname+'_std{0:g}_{1:03d}'.format(std, n)
config.write(configname0, config_c=config_c0, config_v=config_v0, variant=variant, recall_cfg=recall_cfg)