evolutionary-policy-optimization 0.2.8__py3-none-any.whl → 0.2.10__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.
@@ -167,7 +167,8 @@ def shrink_and_perturb_(
167
167
 
168
168
  assert 0. <= shrink_factor <= 1.
169
169
 
170
- maybe_sync_seed()
170
+ device = next(module.parameters()).device
171
+ maybe_sync_seed(device)
171
172
 
172
173
  for p in module.parameters():
173
174
  noise = torch.randn_like(p.data)
@@ -854,10 +855,11 @@ class LatentGenePool(Module):
854
855
  inplace = True,
855
856
  migrate = None # trigger a migration in the setting of multiple islands, the loop outside will need to have some `migrate_every` hyperparameter
856
857
  ):
857
- maybe_sync_seed()
858
858
 
859
859
  device = self.latents.device
860
860
 
861
+ maybe_sync_seed(device)
862
+
861
863
  if not divisible_by(self.step.item(), self.apply_genetic_algorithm_every):
862
864
  self.advance_step_()
863
865
  return
@@ -2,6 +2,7 @@ from random import uniform
2
2
  from copy import deepcopy
3
3
 
4
4
  import torch
5
+ from torch import Tensor
5
6
  import torch.nn.functional as F
6
7
  from torch.func import vmap, functional_call
7
8
  from torch.nn import Module, ParameterList
@@ -14,7 +15,26 @@ def exists(v):
14
15
  def l2norm(t, dim = -1):
15
16
  return F.normalize(t, dim = dim)
16
17
 
17
- def crossover_weights(w1, w2):
18
+ def shrink_and_perturb_(
19
+ t: Tensor,
20
+ shrink_factor = 0.4,
21
+ perturb_factor = 0.1
22
+ ):
23
+ # Shrink & Perturb
24
+ # Ash et al. https://arxiv.org/abs/1910.08475
25
+ # Applied to PBT NAS here https://arxiv.org/abs/2307.15621 - (0.4, 0.1)
26
+
27
+ assert 0. <= shrink_factor <= 1.
28
+ noise = torch.randn_like(t)
29
+ t.mul_(1. - shrink_factor).add_(noise * perturb_factor)
30
+ return t
31
+
32
+ def crossover_weights(
33
+ w1, w2,
34
+ shrink_perturb = False,
35
+ shrink_factor = 0.4,
36
+ perturb_factor = 0.1
37
+ ):
18
38
  assert w2.shape == w2.shape
19
39
 
20
40
  no_batch = w1.ndim == 2
@@ -53,6 +73,9 @@ def crossover_weights(w1, w2):
53
73
  if no_batch:
54
74
  out = rearrange(out, '1 ... -> ...')
55
75
 
76
+ if shrink_perturb:
77
+ shrink_and_perturb_(out, shrink_factor = shrink_factor, perturb_factor = perturb_factor)
78
+
56
79
  return out
57
80
 
58
81
  def mutate_weight(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evolutionary-policy-optimization
3
- Version: 0.2.8
3
+ Version: 0.2.10
4
4
  Summary: EPO - Pytorch
5
5
  Project-URL: Homepage, https://pypi.org/project/evolutionary-policy-optimization/
6
6
  Project-URL: Repository, https://github.com/lucidrains/evolutionary-policy-optimization
@@ -278,4 +278,15 @@ That's it
278
278
  }
279
279
  ```
280
280
 
281
+ ```bibtex
282
+ @article{Chebykin2023ShrinkPerturbIA,
283
+ title = {Shrink-Perturb Improves Architecture Mixing during Population Based Training for Neural Architecture Search},
284
+ author = {Alexander Chebykin and Arkadiy Dushatskiy and Tanja Alderliesten and Peter A. N. Bosman},
285
+ journal = {ArXiv},
286
+ year = {2023},
287
+ volume = {abs/2307.15621},
288
+ url = {https://api.semanticscholar.org/CorpusID:260316291}
289
+ }
290
+ ```
291
+
281
292
  *Evolution is cleverer than you are.* - Leslie Orgel
@@ -0,0 +1,10 @@
1
+ evolutionary_policy_optimization/__init__.py,sha256=NyiYDYU7DlpmOTM7xiBQET3r1WwX0ebrgMCBLSQrW3c,288
2
+ evolutionary_policy_optimization/distributed.py,sha256=MxyxqxANAuOm8GYb0Yu09EHd_aVLhK2uwgrfuVWciPU,2342
3
+ evolutionary_policy_optimization/env_wrappers.py,sha256=bDL06o9_b1iW6k3fw2xifnOnYlzs643tdW6Yv2gsIdw,803
4
+ evolutionary_policy_optimization/epo.py,sha256=adUHDtgrXnSOoPLnbPy6xxGl6QLYxbN1mB_sl2KPwgI,53135
5
+ evolutionary_policy_optimization/experimental.py,sha256=QZG0__wwFqHN_LJK7e-mHxlIL1mwjlvG6o6bcOpeAKg,6166
6
+ evolutionary_policy_optimization/mock_env.py,sha256=TLyyRm6tOD0Kdn9QqJJQriaSnsR-YmNQHo4OohmZFG4,1410
7
+ evolutionary_policy_optimization-0.2.10.dist-info/METADATA,sha256=dLg2z2BFihNUd0dirhDcabw9yNj0V_2v42Tk_Pg-EwY,9601
8
+ evolutionary_policy_optimization-0.2.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ evolutionary_policy_optimization-0.2.10.dist-info/licenses/LICENSE,sha256=1yCiA9b5nhslTavxPjsQAO-wpOnwJR9-l8LTVi7GJuk,1066
10
+ evolutionary_policy_optimization-0.2.10.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- evolutionary_policy_optimization/__init__.py,sha256=NyiYDYU7DlpmOTM7xiBQET3r1WwX0ebrgMCBLSQrW3c,288
2
- evolutionary_policy_optimization/distributed.py,sha256=MxyxqxANAuOm8GYb0Yu09EHd_aVLhK2uwgrfuVWciPU,2342
3
- evolutionary_policy_optimization/env_wrappers.py,sha256=bDL06o9_b1iW6k3fw2xifnOnYlzs643tdW6Yv2gsIdw,803
4
- evolutionary_policy_optimization/epo.py,sha256=San0DS_Z0Ueze6Rz1BKap7SKFww1bx3U0WansTRprdo,53076
5
- evolutionary_policy_optimization/experimental.py,sha256=7LOrMIaU4fr2Vme1ZpHNIvlvFEIdWj0-uemhQoNJcPQ,5549
6
- evolutionary_policy_optimization/mock_env.py,sha256=TLyyRm6tOD0Kdn9QqJJQriaSnsR-YmNQHo4OohmZFG4,1410
7
- evolutionary_policy_optimization-0.2.8.dist-info/METADATA,sha256=PcsHBD4zX1EsV-kWFJIR5fsLxX6hXFPOF4FJyfaI9oU,9171
8
- evolutionary_policy_optimization-0.2.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- evolutionary_policy_optimization-0.2.8.dist-info/licenses/LICENSE,sha256=1yCiA9b5nhslTavxPjsQAO-wpOnwJR9-l8LTVi7GJuk,1066
10
- evolutionary_policy_optimization-0.2.8.dist-info/RECORD,,