l2co-optimizers 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- l2co_optimizers/__init__.py +256 -0
- l2co_optimizers/_src/__init__.py +1 -0
- l2co_optimizers/_src/evosax_implementations.py +603 -0
- l2co_optimizers/_src/experimentdata.py +71 -0
- l2co_optimizers/_src/handshake_policy.py +288 -0
- l2co_optimizers/_src/lbfgs.py +506 -0
- l2co_optimizers/_src/loss.py +88 -0
- l2co_optimizers/_src/mapping.py +100 -0
- l2co_optimizers/_src/menu_eval.py +387 -0
- l2co_optimizers/_src/opt_history.py +200 -0
- l2co_optimizers/_src/optax_implementations.py +542 -0
- l2co_optimizers/_src/optimizer_schedule.py +363 -0
- l2co_optimizers/_src/popsize.py +149 -0
- l2co_optimizers/_src/random_search.py +252 -0
- l2co_optimizers/_src/rbf_trust_region.py +585 -0
- l2co_optimizers/_src/sampler.py +290 -0
- l2co_optimizers/_src/shade.py +667 -0
- l2co_optimizers/_src/state_transfer.py +1364 -0
- l2co_optimizers/_src/stopping_criteria.py +156 -0
- l2co_optimizers/_src/sub_optimizer.py +852 -0
- l2co_optimizers/_src/turbo.py +525 -0
- l2co_optimizers/_src/typing.py +147 -0
- l2co_optimizers/_src/update_class.py +177 -0
- l2co_optimizers/_src/utils.py +24 -0
- l2co_optimizers/conf/__init__.py +5 -0
- l2co_optimizers/conf/optimizers/__init__.py +0 -0
- l2co_optimizers/conf/optimizers/adam.yaml +24 -0
- l2co_optimizers/conf/optimizers/all.yaml +183 -0
- l2co_optimizers/conf/optimizers/contrast.yaml +32 -0
- l2co_optimizers/conf/optimizers/gaussian_classification.yaml +10 -0
- l2co_optimizers/conf/optimizers/headroom4.yaml +26 -0
- l2co_optimizers/conf/optimizers/lr_sweep_pde.yaml +20 -0
- l2co_optimizers/conf/optimizers/medium.yaml +13 -0
- l2co_optimizers/conf/optimizers/pde.yaml +22 -0
- l2co_optimizers/conf/optimizers/sepcmaes.yaml +10 -0
- l2co_optimizers/conf/optimizers/small.yaml +7 -0
- l2co_optimizers/conf/optimizers/standard.yaml +34 -0
- l2co_optimizers/conf/optimizers/standard_no_stopping.yaml +14 -0
- l2co_optimizers/conf/optimizers/supercompressible.yaml +7 -0
- l2co_optimizers/conf/optimizers/two_functions.yaml +14 -0
- l2co_optimizers-0.1.0.dist-info/METADATA +173 -0
- l2co_optimizers-0.1.0.dist-info/RECORD +45 -0
- l2co_optimizers-0.1.0.dist-info/WHEEL +5 -0
- l2co_optimizers-0.1.0.dist-info/licenses/LICENSE +28 -0
- l2co_optimizers-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"""
|
|
2
|
+
L2CO Optimizers - bare optimizers compatible with the L2CO library.
|
|
3
|
+
|
|
4
|
+
The single public surface for using and *authoring* optimizers: the name
|
|
5
|
+
registry and :class:`UpdateClass` container every factory returns, the
|
|
6
|
+
:class:`OptimizationStep` spec the Hydra configs instantiate, the
|
|
7
|
+
optimizer contract types, and the strategy-facing layer (``SubOpt``,
|
|
8
|
+
handshake policy, state transfer, menu evaluation) that meta-optimizers
|
|
9
|
+
dispatch through. Meta-optimization strategies themselves, and the loop
|
|
10
|
+
that runs an optimizer on a task, live in ``l2co``.
|
|
11
|
+
|
|
12
|
+
Tasks reach this package only through :class:`TaskLike`, a structural
|
|
13
|
+
protocol that ``l2co_tasks.Task`` satisfies; neither package imports the
|
|
14
|
+
other.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
# Modules
|
|
18
|
+
# =============================================================================
|
|
19
|
+
|
|
20
|
+
# Registry & construction
|
|
21
|
+
from l2co_optimizers._src.evosax_implementations import (
|
|
22
|
+
evosax_distribution_update,
|
|
23
|
+
evosax_population_update,
|
|
24
|
+
)
|
|
25
|
+
from l2co_optimizers._src.experimentdata import (
|
|
26
|
+
create_schedules_experimentdata,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Handshake policy
|
|
30
|
+
from l2co_optimizers._src.handshake_policy import (
|
|
31
|
+
DEFAULT_HANDSHAKE_POLICY,
|
|
32
|
+
HANDSHAKE_POLICY,
|
|
33
|
+
OPT_STATE_VARIANTS,
|
|
34
|
+
POPULATION_HANDSHAKES,
|
|
35
|
+
POPULATION_VARIANTS,
|
|
36
|
+
HandshakePolicy,
|
|
37
|
+
handshake_policy_for,
|
|
38
|
+
population_best,
|
|
39
|
+
population_best_one,
|
|
40
|
+
population_handshake_for,
|
|
41
|
+
)
|
|
42
|
+
from l2co_optimizers._src.lbfgs import (
|
|
43
|
+
lbfgs_per_eval_key,
|
|
44
|
+
lbfgs_update,
|
|
45
|
+
scale_by_zoom_linesearch_per_eval_key,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# Loss evaluation
|
|
49
|
+
from l2co_optimizers._src.loss import (
|
|
50
|
+
vmapped_loss,
|
|
51
|
+
vmapped_loss_and_grad,
|
|
52
|
+
vmapped_loss_and_grad_with_rng,
|
|
53
|
+
vmapped_loss_with_rng,
|
|
54
|
+
)
|
|
55
|
+
from l2co_optimizers._src.mapping import (
|
|
56
|
+
optimizer_mapping,
|
|
57
|
+
optimizers,
|
|
58
|
+
register_optimizer,
|
|
59
|
+
)
|
|
60
|
+
from l2co_optimizers._src.menu_eval import (
|
|
61
|
+
GRAD_EVALUATION_WIDTH,
|
|
62
|
+
menu_loss_and_grad,
|
|
63
|
+
)
|
|
64
|
+
from l2co_optimizers._src.opt_history import (
|
|
65
|
+
OptHistory,
|
|
66
|
+
RecentHistory,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# Base optimizer factories
|
|
70
|
+
from l2co_optimizers._src.optax_implementations import (
|
|
71
|
+
normalized_optax_from_state,
|
|
72
|
+
normalized_optax_normal,
|
|
73
|
+
optax_update,
|
|
74
|
+
optax_update_extra_kwargs,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# Optimizer specification
|
|
78
|
+
from l2co_optimizers._src.optimizer_schedule import (
|
|
79
|
+
ALIAS_HYPERPARAMETER,
|
|
80
|
+
OptimizationStep,
|
|
81
|
+
register_schedule_namer,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
# Population sizes
|
|
85
|
+
from l2co_optimizers._src.popsize import (
|
|
86
|
+
count_parameters,
|
|
87
|
+
shade_popsize,
|
|
88
|
+
variable_popsize,
|
|
89
|
+
variable_popsize_even,
|
|
90
|
+
)
|
|
91
|
+
from l2co_optimizers._src.random_search import (
|
|
92
|
+
random_search_update,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Samplers
|
|
96
|
+
from l2co_optimizers._src.sampler import (
|
|
97
|
+
constant_sampling,
|
|
98
|
+
get_sampler,
|
|
99
|
+
grid_sampling,
|
|
100
|
+
normal_sampling,
|
|
101
|
+
random_sampling,
|
|
102
|
+
xavier_sampling,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Built-in algorithms
|
|
106
|
+
from l2co_optimizers._src.shade import (
|
|
107
|
+
SHADE,
|
|
108
|
+
shade_update,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# State transfer
|
|
112
|
+
from l2co_optimizers._src.state_transfer import (
|
|
113
|
+
CONF_ABSENT,
|
|
114
|
+
CONF_ESTIMATED,
|
|
115
|
+
CONF_EXACT,
|
|
116
|
+
FAMILIES,
|
|
117
|
+
FAMILY_DISTRIBUTION,
|
|
118
|
+
FAMILY_GRADIENT,
|
|
119
|
+
FAMILY_POPULATION,
|
|
120
|
+
TRANSFER_OVERRIDES,
|
|
121
|
+
TransferBundle,
|
|
122
|
+
TransferSpec,
|
|
123
|
+
build_transfer_fns,
|
|
124
|
+
transfer_spec_for,
|
|
125
|
+
write_none,
|
|
126
|
+
)
|
|
127
|
+
from l2co_optimizers._src.stopping_criteria import (
|
|
128
|
+
STOPPING_CRITERIA,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
# Sub-optimizer adapter
|
|
132
|
+
from l2co_optimizers._src.sub_optimizer import (
|
|
133
|
+
CONSTRUCTOR_HYPERPARAMETERS,
|
|
134
|
+
LINESEARCH_FEVAL_BOUND,
|
|
135
|
+
SubOpt,
|
|
136
|
+
grad_sub_optimizer,
|
|
137
|
+
l2co_native_evosax,
|
|
138
|
+
l2co_native_optax,
|
|
139
|
+
optstep_to_subopt,
|
|
140
|
+
pop_sub_optimizer,
|
|
141
|
+
resolve_popsize,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# Contract types
|
|
145
|
+
from l2co_optimizers._src.typing import (
|
|
146
|
+
AskFunction,
|
|
147
|
+
InitFunction,
|
|
148
|
+
InputParameters,
|
|
149
|
+
LossFunction,
|
|
150
|
+
OptHistoryType,
|
|
151
|
+
OptState,
|
|
152
|
+
PopSize,
|
|
153
|
+
SamplerFunction,
|
|
154
|
+
StepFunction,
|
|
155
|
+
StopFunction,
|
|
156
|
+
TaskLike,
|
|
157
|
+
TransferReadFunction,
|
|
158
|
+
TransferWriteFunction,
|
|
159
|
+
)
|
|
160
|
+
from l2co_optimizers._src.update_class import (
|
|
161
|
+
UpdateClass,
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
# Authorship & Credits
|
|
165
|
+
# =============================================================================
|
|
166
|
+
__author__ = "Martin van der Schelling (m.p.vanderschelling@tudelft.nl)"
|
|
167
|
+
__credits__ = ["Martin van der Schelling"]
|
|
168
|
+
__status__ = "Stable"
|
|
169
|
+
# =============================================================================
|
|
170
|
+
|
|
171
|
+
__all__ = [
|
|
172
|
+
"ALIAS_HYPERPARAMETER",
|
|
173
|
+
"AskFunction",
|
|
174
|
+
"CONF_ABSENT",
|
|
175
|
+
"CONF_ESTIMATED",
|
|
176
|
+
"CONF_EXACT",
|
|
177
|
+
"CONSTRUCTOR_HYPERPARAMETERS",
|
|
178
|
+
"DEFAULT_HANDSHAKE_POLICY",
|
|
179
|
+
"FAMILIES",
|
|
180
|
+
"FAMILY_DISTRIBUTION",
|
|
181
|
+
"FAMILY_GRADIENT",
|
|
182
|
+
"FAMILY_POPULATION",
|
|
183
|
+
"GRAD_EVALUATION_WIDTH",
|
|
184
|
+
"HANDSHAKE_POLICY",
|
|
185
|
+
"HandshakePolicy",
|
|
186
|
+
"InitFunction",
|
|
187
|
+
"InputParameters",
|
|
188
|
+
"LINESEARCH_FEVAL_BOUND",
|
|
189
|
+
"LossFunction",
|
|
190
|
+
"OPT_STATE_VARIANTS",
|
|
191
|
+
"OptHistory",
|
|
192
|
+
"OptHistoryType",
|
|
193
|
+
"OptState",
|
|
194
|
+
"OptimizationStep",
|
|
195
|
+
"POPULATION_HANDSHAKES",
|
|
196
|
+
"POPULATION_VARIANTS",
|
|
197
|
+
"PopSize",
|
|
198
|
+
"RecentHistory",
|
|
199
|
+
"SHADE",
|
|
200
|
+
"STOPPING_CRITERIA",
|
|
201
|
+
"SamplerFunction",
|
|
202
|
+
"StepFunction",
|
|
203
|
+
"StopFunction",
|
|
204
|
+
"SubOpt",
|
|
205
|
+
"TRANSFER_OVERRIDES",
|
|
206
|
+
"TaskLike",
|
|
207
|
+
"TransferBundle",
|
|
208
|
+
"TransferReadFunction",
|
|
209
|
+
"TransferSpec",
|
|
210
|
+
"TransferWriteFunction",
|
|
211
|
+
"UpdateClass",
|
|
212
|
+
"build_transfer_fns",
|
|
213
|
+
"constant_sampling",
|
|
214
|
+
"count_parameters",
|
|
215
|
+
"create_schedules_experimentdata",
|
|
216
|
+
"evosax_distribution_update",
|
|
217
|
+
"evosax_population_update",
|
|
218
|
+
"get_sampler",
|
|
219
|
+
"grad_sub_optimizer",
|
|
220
|
+
"grid_sampling",
|
|
221
|
+
"handshake_policy_for",
|
|
222
|
+
"l2co_native_evosax",
|
|
223
|
+
"l2co_native_optax",
|
|
224
|
+
"lbfgs_per_eval_key",
|
|
225
|
+
"lbfgs_update",
|
|
226
|
+
"menu_loss_and_grad",
|
|
227
|
+
"normal_sampling",
|
|
228
|
+
"normalized_optax_from_state",
|
|
229
|
+
"normalized_optax_normal",
|
|
230
|
+
"optax_update",
|
|
231
|
+
"optax_update_extra_kwargs",
|
|
232
|
+
"optimizer_mapping",
|
|
233
|
+
"optimizers",
|
|
234
|
+
"optstep_to_subopt",
|
|
235
|
+
"pop_sub_optimizer",
|
|
236
|
+
"population_best",
|
|
237
|
+
"population_best_one",
|
|
238
|
+
"population_handshake_for",
|
|
239
|
+
"random_sampling",
|
|
240
|
+
"random_search_update",
|
|
241
|
+
"register_optimizer",
|
|
242
|
+
"register_schedule_namer",
|
|
243
|
+
"resolve_popsize",
|
|
244
|
+
"scale_by_zoom_linesearch_per_eval_key",
|
|
245
|
+
"shade_popsize",
|
|
246
|
+
"shade_update",
|
|
247
|
+
"transfer_spec_for",
|
|
248
|
+
"variable_popsize",
|
|
249
|
+
"variable_popsize_even",
|
|
250
|
+
"vmapped_loss",
|
|
251
|
+
"vmapped_loss_and_grad",
|
|
252
|
+
"vmapped_loss_and_grad_with_rng",
|
|
253
|
+
"vmapped_loss_with_rng",
|
|
254
|
+
"write_none",
|
|
255
|
+
"xavier_sampling",
|
|
256
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Implementation of ``l2co_optimizers``; import from the package root."""
|