-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulations.py
175 lines (170 loc) · 4.95 KB
/
simulations.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import corpora
import network
DEFAULT_ACTIVATIONS = (
network.SIGMOID,
network.LINEAR,
network.RELU,
network.SQUARE,
network.UNSIGNED_STEP,
network.FLOOR,
)
EXTENDED_ACTIVATIONS = DEFAULT_ACTIVATIONS + (network.MODULO_2, network.MODULO_3,)
DEFAULT_UNIT_TYPES = (network.SUMMATION_UNIT,)
DEFAULT_CONFIG = {
"migration_ratio": 0.01,
"migration_interval_seconds": 1800,
"migration_interval_generations": 1000,
"num_generations": 25_000,
"population_size": 500,
"elite_ratio": 0.001,
"allowed_activations": DEFAULT_ACTIVATIONS,
"allowed_unit_types": DEFAULT_UNIT_TYPES,
"start_smooth": False,
"compress_grammar_encoding": False,
"tournament_size": 2,
"mutation_probab": 1.0,
"mini_batch_size": None,
"grammar_multiplier": 1,
"data_given_grammar_multiplier": 1,
"max_network_units": 1024,
"softmax_outputs": False,
"truncate_large_values": True,
"bias_connections": True,
"recurrent_connections": True,
"corpus_seed": 100,
"parallelize": True,
"migration_channel": "file",
"generation_dump_interval": 250,
}
SIMULATIONS = {
"identity": {
"corpus": {
"factory": corpora.make_identity_binary,
"args": {"sequence_length": 100, "batch_size": 10},
}
},
"repeat_last_char": {
"corpus": {
"factory": corpora.make_prev_char_repetition_binary,
"args": {"sequence_length": 100, "batch_size": 10, "repetition_offset": 1,},
}
},
"binary_addition": {
"corpus": {
"factory": corpora.make_binary_addition,
"args": {"min_n": 0, "max_n": 20},
},
},
"dyck_1": {
"corpus": {
"factory": corpora.make_dyck_n,
"args": {
"n": 1,
"batch_size": 100,
"nesting_probab": 0.3,
"max_sequence_length": 200,
},
},
},
"dyck_2": {
"corpus": {
"factory": corpora.make_dyck_n,
"args": {
"batch_size": 20_000,
"nesting_probab": 0.3,
"n": 2,
"max_sequence_length": 200,
},
},
"config": {
"allowed_activations": EXTENDED_ACTIVATIONS,
"allowed_unit_types": (network.SUMMATION_UNIT, network.MULTIPLICATION_UNIT),
},
},
"an_bn": {
"corpus": {
"factory": corpora.make_ain_bjn_ckn_dtn,
"args": {"batch_size": 100, "prior": 0.3, "multipliers": (1, 1, 0, 0)},
}
},
"an_bn_cn": {
"corpus": {
"factory": corpora.make_ain_bjn_ckn_dtn,
"args": {"batch_size": 100, "prior": 0.3, "multipliers": (1, 1, 1, 0)},
}
},
"an_bn_cn_dn": {
"corpus": {
"factory": corpora.make_ain_bjn_ckn_dtn,
"args": {"batch_size": 100, "prior": 0.3, "multipliers": (1, 1, 1, 1)},
}
},
"an_b2n": {
"corpus": {
"factory": corpora.make_ain_bjn_ckn_dtn,
"args": {"batch_size": 100, "prior": 0.3, "multipliers": (1, 2, 0, 0)},
}
},
"an_bn_square": {
"corpus": {
"factory": corpora.make_an_bn_square,
"args": {"batch_size": 1000, "prior": 0.5},
}
},
"palindrome_fixed_length": {
"corpus": {
"factory": corpora.make_binary_palindrome_fixed_length,
"args": {
"batch_size": 1000,
"sequence_length": 50,
"train_set_ratio": 0.7,
},
}
},
"an_bm_cn_plus_m": {
"corpus": {
"factory": corpora.make_an_bm_cn_plus_m,
"args": {"batch_size": 100, "prior": 0.3},
}
},
"center_embedding": {
"corpus": {
"factory": corpora.make_center_embedding,
"args": {
"batch_size": 20_000,
"embedding_depth_probab": 0.3,
"dependency_distance_probab": 0.0,
},
},
"config": {
"allowed_activations": DEFAULT_ACTIVATIONS + (network.MODULO_2,),
"allowed_unit_types": (network.SUMMATION_UNIT, network.MULTIPLICATION_UNIT),
},
},
"0_1_pattern_binary": {
"corpus": {
"factory": corpora.make_0_1_pattern_binary,
"args": {"sequence_length": 20, "batch_size": 1},
}
},
"0_1_pattern_one_hot_no_eos": {
"corpus": {
"factory": corpora.make_0_1_pattern_one_hot,
"args": {
"add_end_of_sequence": False,
"sequence_length": 50,
"batch_size": 1,
},
}
},
"0_1_pattern_one_hot_with_eos": {
"corpus": {
"factory": corpora.make_0_1_pattern_one_hot,
"args": {
"add_end_of_sequence": True,
"sequence_length": 50,
"batch_size": 1,
},
}
},
}