add example for recurrent network
This commit is contained in:
40
examples/brax/hopper_recurrent.py
Normal file
40
examples/brax/hopper_recurrent.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
from tensorneat.pipeline import Pipeline
|
||||||
|
from tensorneat.algorithm.neat import NEAT
|
||||||
|
from tensorneat.genome import RecurrentGenome, BiasNode
|
||||||
|
|
||||||
|
from tensorneat.problem.rl import BraxEnv
|
||||||
|
from tensorneat.common import ACT, AGG
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
pipeline = Pipeline(
|
||||||
|
algorithm=NEAT(
|
||||||
|
pop_size=1000,
|
||||||
|
species_size=20,
|
||||||
|
survival_threshold=0.1,
|
||||||
|
compatibility_threshold=1.0,
|
||||||
|
genome=RecurrentGenome(
|
||||||
|
num_inputs=11,
|
||||||
|
num_outputs=3,
|
||||||
|
init_hidden_layers=(),
|
||||||
|
node_gene=BiasNode(
|
||||||
|
activation_options=ACT.tanh,
|
||||||
|
aggregation_options=AGG.sum,
|
||||||
|
),
|
||||||
|
output_transform=ACT.tanh,
|
||||||
|
activate_time=20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
problem=BraxEnv(
|
||||||
|
env_name="hopper",
|
||||||
|
max_step=1000,
|
||||||
|
),
|
||||||
|
seed=42,
|
||||||
|
generation_limit=100,
|
||||||
|
fitness_target=5000,
|
||||||
|
)
|
||||||
|
|
||||||
|
# initialize state
|
||||||
|
state = pipeline.setup()
|
||||||
|
# print(state)
|
||||||
|
# run until terminate
|
||||||
|
state, best = pipeline.auto_run(state)
|
||||||
Reference in New Issue
Block a user