forked from coreyjadams/CosmicTagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_configs.py
68 lines (51 loc) · 2.26 KB
/
generate_configs.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
import sys, os
import random
from omegaconf import OmegaConf
for i in range(10):
# Load the default config:
conf = OmegaConf.load('src/config/config.yaml')
output_config_name = f"src/config/image_scaling_configs/config{i}.yaml"
# Generate a suite of config options:
configuration = {
"defaults" :
[ {"network": "uresnet"},
{"framework": "tensorflow"},
{"mode": "training"},
{"data": "real"},
],
"run": {
"distributed" : False,
"compute_mode" : "GPU",
"iterations" : 50,
"minibatch_size" : 2,
"aux_minibatch_size" : "${run.minibatch_size}",
"aux_iterations" : 10,
"id" : "???",
"precision" : "float32",
"profile" : False,
"output_dir" : "output/${framework.name}/${network.name}/${run.id}/",
}
}
# Minibatch size must be an even multiple of 16, and at least 64 but less than 128
mb = random.choice([128,192])
conf['compute_mode'] = {'minibatch_size' : mb}
# Make sure we run for 25 epochs:
conf['run']['iterations'] = int(25 * 43075 / mb)
# Network parameters:
conf['network'] = {}
conf['network']['bias'] = random.choice([True, False])
conf['network']['batch_norm'] = random.choice([True, False])
conf['network']['n_initial_filters'] = 8*random.randint(1,4)
conf['network']['blocks_per_layer'] = random.randint(1,3)
conf['network']['blocks_deepest_layer'] = random.randint(1,5)
conf['network']['blocks_final'] = random.randint(0,5)
conf['network']['bottleneck_deepest'] = 8*random.randint(1,32)
conf['network']['residual'] = random.choice([True, False])
conf['network']['downsampling'] = random.choice(["max_pooling", "convolutional"])
conf['network']['upsampling'] = random.choice(["interpolation", "convolutional"])
conf['network']['connections'] = random.choice(["concat", "sum"])
conf['mode'] = {}
conf['mode']['optimizer'] = {}
conf['mode']['optimizer']['learning_rate'] = 10.**random.uniform(-3.5, -2.5)
conf['mode']['optimizer']['loss_balance_scheme'] = random.choice(["none", "light", "focal"])
OmegaConf.save(conf, output_config_name)