add sympy support; which can transfer your network into sympy expression;
add visualize in genome; add related tests.
This commit is contained in:
30
tensorneat/examples/interpret_visualize/genome_sympy.py
Normal file
30
tensorneat/examples/interpret_visualize/genome_sympy.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import jax, jax.numpy as jnp
|
||||
|
||||
from algorithm.neat import *
|
||||
from algorithm.neat.genome.advance import AdvanceInitialize
|
||||
from utils.graph import topological_sort_python
|
||||
|
||||
if __name__ == '__main__':
|
||||
genome = AdvanceInitialize(
|
||||
num_inputs=17,
|
||||
num_outputs=6,
|
||||
hidden_cnt=8,
|
||||
max_nodes=50,
|
||||
max_conns=500,
|
||||
)
|
||||
|
||||
state = genome.setup()
|
||||
|
||||
randkey = jax.random.PRNGKey(42)
|
||||
nodes, conns = genome.initialize(state, randkey)
|
||||
|
||||
network = genome.network_dict(state, nodes, conns)
|
||||
print(set(network["nodes"]), set(network["conns"]))
|
||||
order, _ = topological_sort_python(set(network["nodes"]), set(network["conns"]))
|
||||
print(order)
|
||||
|
||||
input_idx, output_idx = genome.get_input_idx(), genome.get_output_idx()
|
||||
print(input_idx, output_idx)
|
||||
|
||||
print(genome.repr(state, nodes, conns))
|
||||
print(network)
|
||||
Reference in New Issue
Block a user