odify genome for the official release
This commit is contained in:
488
examples/interpret_visualize/genome_sympy.ipynb
Normal file
488
examples/interpret_visualize/genome_sympy.ipynb
Normal file
File diff suppressed because one or more lines are too long
37
examples/interpret_visualize/genome_sympy.py
Normal file
37
examples/interpret_visualize/genome_sympy.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import jax, jax.numpy as jnp
|
||||
|
||||
from algorithm.neat import *
|
||||
from algorithm.neat.genome.dense import DenseInitialize
|
||||
from utils.graph import topological_sort_python
|
||||
from tensorneat.common import *
|
||||
|
||||
if __name__ == "__main__":
|
||||
genome = DenseInitialize(
|
||||
num_inputs=3,
|
||||
num_outputs=1,
|
||||
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)
|
||||
|
||||
input_idx, output_idx = genome.get_input_idx(), genome.get_output_idx()
|
||||
|
||||
res = genome.sympy_func(state, network, sympy_input_transform=lambda x: 999999999*x, sympy_output_transform=SympyStandardSigmoid)
|
||||
(symbols,
|
||||
args_symbols,
|
||||
input_symbols,
|
||||
nodes_exprs,
|
||||
output_exprs,
|
||||
forward_func,) = res
|
||||
|
||||
print(symbols)
|
||||
print(output_exprs[0].subs(args_symbols))
|
||||
|
||||
inputs = jnp.zeros(3)
|
||||
print(forward_func(inputs))
|
||||
2455
examples/interpret_visualize/graph.svg
Normal file
2455
examples/interpret_visualize/graph.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 90 KiB |
191
examples/interpret_visualize/network.json
Normal file
191
examples/interpret_visualize/network.json
Normal file
@@ -0,0 +1,191 @@
|
||||
{
|
||||
"nodes": {
|
||||
"0": {
|
||||
"bias": 0.13710324466228485,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"1": {
|
||||
"bias": -1.4202250242233276,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"2": {
|
||||
"bias": -0.4653860926628113,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"3": {
|
||||
"bias": 0.5835710167884827,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"4": {
|
||||
"bias": 2.187405824661255,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"5": {
|
||||
"bias": 0.24963024258613586,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"6": {
|
||||
"bias": -0.966821551322937,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"7": {
|
||||
"bias": 0.4452081620693207,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"8": {
|
||||
"bias": -0.07293166220188141,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"9": {
|
||||
"bias": -0.1625899225473404,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"10": {
|
||||
"bias": -0.8576332330703735,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"11": {
|
||||
"bias": -0.18487468361854553,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"12": {
|
||||
"bias": 1.4335486888885498,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"13": {
|
||||
"bias": -0.8690621256828308,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"14": {
|
||||
"bias": -0.23014676570892334,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"15": {
|
||||
"bias": 0.7880322337150574,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"16": {
|
||||
"bias": -0.22258250415325165,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"17": {
|
||||
"bias": 0.2773352861404419,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"18": {
|
||||
"bias": -0.40279051661491394,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"19": {
|
||||
"bias": 1.092000961303711,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"20": {
|
||||
"bias": -0.4063087999820709,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"21": {
|
||||
"bias": 0.3895529806613922,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"22": {
|
||||
"bias": -0.18007506430149078,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"23": {
|
||||
"bias": -0.8112533092498779,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"24": {
|
||||
"bias": 0.2946726381778717,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"25": {
|
||||
"bias": -1.118497371673584,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"26": {
|
||||
"bias": 1.3674490451812744,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"27": {
|
||||
"bias": -1.6514816284179688,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"28": {
|
||||
"bias": 0.9440701603889465,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"29": {
|
||||
"bias": 1.564852237701416,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
},
|
||||
"30": {
|
||||
"bias": -0.5568665266036987,
|
||||
"res": 1.0,
|
||||
"agg": "sum",
|
||||
"act": "sigmoid"
|
||||
}
|
||||
},
|
||||
"conns": {
|
||||
|
||||
2455
examples/interpret_visualize/network.svg
Normal file
2455
examples/interpret_visualize/network.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 89 KiB |
103
examples/interpret_visualize/visualize_genome.ipynb
Normal file
103
examples/interpret_visualize/visualize_genome.ipynb
Normal file
File diff suppressed because one or more lines are too long
13
examples/interpret_visualize/visualize_genome.py
Normal file
13
examples/interpret_visualize/visualize_genome.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import networkx as nx
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# 创建一个空白的有向图
|
||||
G = nx.DiGraph()
|
||||
|
||||
# 添加边
|
||||
G.add_edge('A', 'B')
|
||||
G.add_edge('A', 'C')
|
||||
G.add_edge('B', 'C')
|
||||
G.add_edge('C', 'D')
|
||||
|
||||
# 绘制有向图
|
||||
Reference in New Issue
Block a user