evolutionary-policy-optimization 0.2.9__tar.gz → 0.2.11__tar.gz

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.
Files changed (18) hide show
  1. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/PKG-INFO +12 -1
  2. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/README.md +11 -0
  3. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/evolutionary_policy_optimization/distributed.py +3 -1
  4. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/evolutionary_policy_optimization/experimental.py +24 -1
  5. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/pyproject.toml +1 -1
  6. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/tests/test_epo.py +2 -1
  7. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/.github/workflows/lint.yml +0 -0
  8. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/.github/workflows/python-publish.yml +0 -0
  9. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/.github/workflows/test.yml +0 -0
  10. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/.gitignore +0 -0
  11. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/LICENSE +0 -0
  12. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/evolutionary_policy_optimization/__init__.py +0 -0
  13. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/evolutionary_policy_optimization/env_wrappers.py +0 -0
  14. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/evolutionary_policy_optimization/epo.py +0 -0
  15. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/evolutionary_policy_optimization/mock_env.py +0 -0
  16. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/requirements.txt +0 -0
  17. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/train_crossover_weight_space.py +0 -0
  18. {evolutionary_policy_optimization-0.2.9 → evolutionary_policy_optimization-0.2.11}/train_gym.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evolutionary-policy-optimization
3
- Version: 0.2.9
3
+ Version: 0.2.11
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
@@ -221,4 +221,15 @@ That's it
221
221
  }
222
222
  ```
223
223
 
224
+ ```bibtex
225
+ @article{Chebykin2023ShrinkPerturbIA,
226
+ title = {Shrink-Perturb Improves Architecture Mixing during Population Based Training for Neural Architecture Search},
227
+ author = {Alexander Chebykin and Arkadiy Dushatskiy and Tanja Alderliesten and Peter A. N. Bosman},
228
+ journal = {ArXiv},
229
+ year = {2023},
230
+ volume = {abs/2307.15621},
231
+ url = {https://api.semanticscholar.org/CorpusID:260316291}
232
+ }
233
+ ```
234
+
224
235
  *Evolution is cleverer than you are.* - Leslie Orgel
@@ -61,6 +61,8 @@ def has_only_one_value(t):
61
61
  return (t == t[0]).all()
62
62
 
63
63
  def all_gather_variable_dim(t, dim = 0, sizes = None):
64
+ device = t.device
65
+
64
66
  if not exists(sizes):
65
67
  sizes = gather_sizes(t, dim = dim)
66
68
 
@@ -77,7 +79,7 @@ def all_gather_variable_dim(t, dim = 0, sizes = None):
77
79
  gathered_tensors = torch.cat(gathered_tensors, dim = dim)
78
80
  seq = torch.arange(max_size, device = device)
79
81
 
80
- mask = einx.less('j i -> (i j)', seq, sizes)
82
+ mask = einx.less('j, i -> (i j)', seq, sizes)
81
83
  seq = torch.arange(mask.shape[-1], device = device)
82
84
  indices = seq[mask]
83
85
 
@@ -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
  [project]
2
2
  name = "evolutionary-policy-optimization"
3
- version = "0.2.9"
3
+ version = "0.2.11"
4
4
  description = "EPO - Pytorch"
5
5
  authors = [
6
6
  { name = "Phil Wang", email = "lucidrains@gmail.com" }
@@ -58,7 +58,8 @@ def test_create_agent(
58
58
  actor_dim = 256,
59
59
  actor_mlp_depth = 2,
60
60
  critic_dim = 256,
61
- critic_mlp_depth = 4
61
+ critic_mlp_depth = 4,
62
+ wrap_with_accelerate = False
62
63
  )
63
64
 
64
65
  state = torch.randn(2, 512)