complete fully stateful!

use black to format all files!
This commit is contained in:
wls2002
2024-05-26 18:08:43 +08:00
parent cf69b916af
commit 18c3d44c79
41 changed files with 620 additions and 495 deletions

View File

@@ -10,11 +10,7 @@ from problem.rl_env import GymNaxConfig, GymNaxEnv
def example_conf():
return Config(
basic=BasicConfig(
seed=42,
fitness_target=500,
pop_size=10000
),
basic=BasicConfig(seed=42, fitness_target=500, pop_size=10000),
neat=NeatConfig(
inputs=4,
outputs=1,
@@ -23,28 +19,31 @@ def example_conf():
activation_default=Act.tanh,
activation_options=(Act.tanh,),
),
hyperneat=HyperNeatConfig(
activation=Act.sigmoid,
inputs=4,
outputs=2
),
hyperneat=HyperNeatConfig(activation=Act.sigmoid, inputs=4, outputs=2),
substrate=NormalSubstrateConfig(
input_coors=((-1, -1), (-0.5, -1), (0, -1), (0.5, -1), (1, -1)),
hidden_coors=(
# (-1, -0.5), (-0.5, -0.5), (0, -0.5), (0.5, -0.5),
(1, 0), (-1, 0), (-0.5, 0), (0, 0), (0.5, 0), (1, 0),
(1, 0),
(-1, 0),
(-0.5, 0),
(0, 0),
(0.5, 0),
(1, 0),
# (1, 0.5), (-1, 0.5), (-0.5, 0.5), (0, 0.5), (0.5, 0.5), (1, 0.5),
),
output_coors=((-1, 1), (1, 1)),
),
problem=GymNaxConfig(
env_name='CartPole-v1',
output_transform=lambda out: jnp.argmax(out) # the action of cartpole is {0, 1}
)
env_name="CartPole-v1",
output_transform=lambda out: jnp.argmax(
out
), # the action of cartpole is {0, 1}
),
)
if __name__ == '__main__':
if __name__ == "__main__":
conf = example_conf()
algorithm = HyperNEAT(conf, NormalGene, NormalSubstrate)