HyperGP.executor Module#
- executor(progs, input, pset, cashset=None)[source]#
Execute the GP programs
- Parameters:
progs (list) – The GP programs need to be executed.
input (
HyperGP.Tensorornumpy.ndarrayorlist) – shape = (feature size, …)pset (
HyperGP.PrimitiveSet) – used for the progscashset (CashManager)
- Returns:
The outputs generated by the progs with the given inputs. records: The outputs of the record nodes.
- Return type:
outputs
Examples
>>> from HyperGP import executor, PrimitiveSet, Population >>> import numpy as np
>>> # Generae the primitive set >>> pset = PrimitiveSet( input_arity=1, primitive_set=[ ('add', HyperGP.add, 2), ('sub', HyperGP.sub, 2), ('mul', HyperGP.mul, 2), ('div', HyperGP.div, 2), ])
>>> # Generate the input data >>> input_array = Tensor(np.random.uniform(0, 10, size=(1, 10000)))
>>> # Initialize the population >>> pop = Population() >>> pstates = ProgBuildStates(pset=pset, depth_rg=[2, 6], len_limit=100) >>> pop.initPop(pop_size=pop_size, prog_paras=pstates)
>>> # Execute the individuals >>> output, _ = executor(pop.states['progs'].indivs, input_array, pset)