Upload neat\base_ne.py with huggingface_hub
Browse files- neat//base_ne.py +15 -0
neat//base_ne.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import jax.numpy as jnp
|
| 2 |
+
|
| 3 |
+
class NEAlgorithm:
|
| 4 |
+
"""Base class for neuroevolution algorithms"""
|
| 5 |
+
def __init__(self):
|
| 6 |
+
self.gen = 0
|
| 7 |
+
self.pop = []
|
| 8 |
+
|
| 9 |
+
def ask(self) -> jnp.ndarray:
|
| 10 |
+
"""Return current population parameters"""
|
| 11 |
+
raise NotImplementedError
|
| 12 |
+
|
| 13 |
+
def tell(self, fitness_array: jnp.ndarray) -> None:
|
| 14 |
+
"""Update population based on fitness values"""
|
| 15 |
+
raise NotImplementedError
|