complete HyperNEAT!

This commit is contained in:
wls2002
2023-07-21 15:03:12 +08:00
parent 80ee5ea2ea
commit 48f90c7eef
32 changed files with 432 additions and 136 deletions

View File

@@ -0,0 +1,56 @@
import numpy as np
from algorithm.hyperneat.substrate.tools import cartesian_product
def test01():
keys1 = np.array([1, 2, 3])
keys2 = np.array([4, 5, 6, 7])
coors1 = np.array([
[1, 1, 1],
[2, 2, 2],
[3, 3, 3]
])
coors2 = np.array([
[4, 4, 4],
[5, 5, 5],
[6, 6, 6],
[7, 7, 7]
])
target_coors = np.array([
[1, 1, 1, 4, 4, 4],
[1, 1, 1, 5, 5, 5],
[1, 1, 1, 6, 6, 6],
[1, 1, 1, 7, 7, 7],
[2, 2, 2, 4, 4, 4],
[2, 2, 2, 5, 5, 5],
[2, 2, 2, 6, 6, 6],
[2, 2, 2, 7, 7, 7],
[3, 3, 3, 4, 4, 4],
[3, 3, 3, 5, 5, 5],
[3, 3, 3, 6, 6, 6],
[3, 3, 3, 7, 7, 7]
])
target_keys = np.array([
[1, 4],
[1, 5],
[1, 6],
[1, 7],
[2, 4],
[2, 5],
[2, 6],
[2, 7],
[3, 4],
[3, 5],
[3, 6],
[3, 7]
])
new_coors, correspond_keys = cartesian_product(keys1, keys2, coors1, coors2)
assert np.array_equal(new_coors, target_coors)
assert np.array_equal(correspond_keys, target_keys)

View File

@@ -1,7 +1,7 @@
import jax.numpy as jnp
from algorithm.neat.genome.graph import topological_sort, check_cycles
from algorithm.neat.utils import I_INT
from algorithm.utils import I_INT
nodes = jnp.array([
[0],

View File

@@ -1,5 +1,5 @@
import jax.numpy as jnp
from algorithm.neat.utils import unflatten_connections
from algorithm.utils import unflatten_connections
def test_unflatten():