update some examples
This commit is contained in:
@@ -1,36 +1,45 @@
|
||||
import jax.numpy as jnp
|
||||
|
||||
from pipeline import Pipeline
|
||||
from algorithm.neat import *
|
||||
from tensorneat.pipeline import Pipeline
|
||||
from tensorneat.algorithm.neat import NEAT
|
||||
from tensorneat.genome import DefaultGenome, BiasNode
|
||||
|
||||
from tensorneat.problem.rl import GymNaxEnv
|
||||
from tensorneat.common import Act, Agg
|
||||
|
||||
|
||||
from problem.rl_env import GymNaxEnv
|
||||
|
||||
if __name__ == "__main__":
|
||||
# the network has 3 outputs, the max one will be the action
|
||||
# as the action of acrobot is {0, 1, 2}
|
||||
|
||||
pipeline = Pipeline(
|
||||
algorithm=NEAT(
|
||||
species=DefaultSpecies(
|
||||
genome=DefaultGenome(
|
||||
num_inputs=6,
|
||||
num_outputs=3,
|
||||
max_nodes=50,
|
||||
max_conns=100,
|
||||
output_transform=lambda out: jnp.argmax(
|
||||
out
|
||||
), # the action of acrobot is {0, 1, 2}
|
||||
pop_size=1000,
|
||||
species_size=20,
|
||||
survival_threshold=0.1,
|
||||
compatibility_threshold=1.0,
|
||||
genome=DefaultGenome(
|
||||
num_inputs=6,
|
||||
num_outputs=3,
|
||||
init_hidden_layers=(),
|
||||
node_gene=BiasNode(
|
||||
activation_options=Act.tanh,
|
||||
aggregation_options=Agg.sum,
|
||||
),
|
||||
pop_size=10000,
|
||||
species_size=10,
|
||||
output_transform=jnp.argmax,
|
||||
),
|
||||
),
|
||||
problem=GymNaxEnv(
|
||||
env_name="Acrobot-v1",
|
||||
),
|
||||
generation_limit=10000,
|
||||
fitness_target=-62,
|
||||
seed=42,
|
||||
generation_limit=100,
|
||||
fitness_target=-60,
|
||||
)
|
||||
|
||||
# initialize state
|
||||
state = pipeline.setup()
|
||||
# print(state)
|
||||
|
||||
# run until terminate
|
||||
state, best = pipeline.auto_run(state)
|
||||
|
||||
Reference in New Issue
Block a user