evolutionary-policy-optimization 0.2.9__py3-none-any.whl → 0.2.11__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.
- evolutionary_policy_optimization/distributed.py +3 -1
- evolutionary_policy_optimization/experimental.py +24 -1
- {evolutionary_policy_optimization-0.2.9.dist-info → evolutionary_policy_optimization-0.2.11.dist-info}/METADATA +12 -1
- evolutionary_policy_optimization-0.2.11.dist-info/RECORD +10 -0
- evolutionary_policy_optimization-0.2.9.dist-info/RECORD +0 -10
- {evolutionary_policy_optimization-0.2.9.dist-info → evolutionary_policy_optimization-0.2.11.dist-info}/WHEEL +0 -0
- {evolutionary_policy_optimization-0.2.9.dist-info → evolutionary_policy_optimization-0.2.11.dist-info}/licenses/LICENSE +0 -0
@@ -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
|
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.
|
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
|
@@ -0,0 +1,10 @@
|
|
1
|
+
evolutionary_policy_optimization/__init__.py,sha256=NyiYDYU7DlpmOTM7xiBQET3r1WwX0ebrgMCBLSQrW3c,288
|
2
|
+
evolutionary_policy_optimization/distributed.py,sha256=clN8Bvhb6JIQy2F8FTF312B0RN3iYoPkKjZreBtAwks,2366
|
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.11.dist-info/METADATA,sha256=uLwSfXZcnP4eNG_HxYK7DP46VxCjjco-JxPOT1GoOgw,9601
|
8
|
+
evolutionary_policy_optimization-0.2.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
9
|
+
evolutionary_policy_optimization-0.2.11.dist-info/licenses/LICENSE,sha256=1yCiA9b5nhslTavxPjsQAO-wpOnwJR9-l8LTVi7GJuk,1066
|
10
|
+
evolutionary_policy_optimization-0.2.11.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=adUHDtgrXnSOoPLnbPy6xxGl6QLYxbN1mB_sl2KPwgI,53135
|
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.9.dist-info/METADATA,sha256=sf6iwunGaiuum2yoHwFpanhi9JGwNg621VyZ9H7z_yI,9171
|
8
|
-
evolutionary_policy_optimization-0.2.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
9
|
-
evolutionary_policy_optimization-0.2.9.dist-info/licenses/LICENSE,sha256=1yCiA9b5nhslTavxPjsQAO-wpOnwJR9-l8LTVi7GJuk,1066
|
10
|
-
evolutionary_policy_optimization-0.2.9.dist-info/RECORD,,
|
File without changes
|