change a lot
This commit is contained in:
4
examples/config_test.py
Normal file
4
examples/config_test.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from algorithm.config import Configer
|
||||
|
||||
config = Configer.load_config()
|
||||
print(config)
|
||||
@@ -1,6 +1,8 @@
|
||||
import jax
|
||||
from jax import numpy as jnp
|
||||
from algorithm.state import State
|
||||
|
||||
|
||||
@jax.jit
|
||||
def func(state: State, a):
|
||||
return state.update(a=a)
|
||||
@@ -9,6 +11,5 @@ def func(state: State, a):
|
||||
state = State(c=1, b=2)
|
||||
print(state)
|
||||
|
||||
state = func(state, 1111111)
|
||||
|
||||
print(state)
|
||||
vmap_func = jax.vmap(func, in_axes=(None, 0))
|
||||
print(vmap_func(state, jnp.array([1, 2, 3])))
|
||||
16
examples/xor_test.py
Normal file
16
examples/xor_test.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import jax
|
||||
|
||||
from algorithm.config import Configer
|
||||
from algorithm.neat import NEAT
|
||||
from algorithm.neat.genome import create_mutate
|
||||
|
||||
if __name__ == '__main__':
|
||||
config = Configer.load_config()
|
||||
neat = NEAT(config)
|
||||
randkey = jax.random.PRNGKey(42)
|
||||
state = neat.setup(randkey)
|
||||
mutate_func = jax.jit(create_mutate(config, neat.gene_type))
|
||||
state = mutate_func(state)
|
||||
print(state)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user