change str in config (act, agg) from str to callable

This commit is contained in:
wls2002
2023-08-05 03:03:02 +08:00
parent 0e44b13291
commit af54db3b12
10 changed files with 55 additions and 101 deletions

View File

@@ -6,7 +6,7 @@ import numpy as np
from config import Config, HyperNeatConfig
from core import Algorithm, Substrate, State, Genome, Gene
from utils import Activation, Aggregation
from utils import Act, Agg
from .substrate import analysis_substrate
from algorithm import NEAT
@@ -90,10 +90,7 @@ class HyperNEATGene:
@staticmethod
def forward(config: HyperNeatConfig, state: State, inputs, transformed):
act = Activation.name2func[config.activation]
agg = Aggregation.name2func[config.aggregation]
batch_act, batch_agg = jax.vmap(act), jax.vmap(agg)
batch_act, batch_agg = jax.vmap(config.activation), jax.vmap(config.aggregation)
nodes, weights = transformed