pub struct EneCode {
pub neuron_id: Vec<String>,
pub topology: Vec<TopologyGene>,
pub neuronal_props: NeuronalPropertiesGene,
pub meta_learning: MetaLearningGene,
}Expand description
EneCode encapsulates the genetic blueprint for constructing an entire neural network.
This struct holds all the information required to instantiate a neural network with distinct neurons, synaptic connections, and meta-learning parameters. It consists of a collection of genes that provide the blueprint for each individual neuron’s topology, its neuronal properties, and meta-learning rules.
§Fields
-
neuron_id- A vector containing the unique identifiers for each neuron in the genome. These IDs are used to find the associated topology gene for each neuron. -
topology- A list ofTopologyGenestructs that describe the synaptic connections, neuron types, and other topological features for each neuron in the network. -
neuronal_props- An instance ofNeuronalPropertiesGenethat provides global neuronal properties like time constants, homeostatic forces, and activation function scaling factors. -
meta_learning- An instance ofMetaLearningGenethat provides meta-learning parameters such as learning rate and learning thresholds for synaptic adjustments.
§Example Usage
use evo_rl::enecode::EneCode;
use evo_rl::enecode::TopologyGene;
use evo_rl::enecode::NeuronalPropertiesGene;
use evo_rl::enecode::MetaLearningGene;
use evo_rl::enecode::NeuronType;
// Initialization (example)
let genome = EneCode::new_from_genome (
vec![
TopologyGene {
innovation_number: Arc::from("N1"),
pin: NeuronType::In,
inputs: HashMap::new(),
genetic_bias: 0.1,
active: true
},
// ... more TopologyGene
],
NeuronalPropertiesGene {
innovation_number: Arc::from("NP01"),
tau: 0.9,
homeostatic_force: 0.1,
tanh_alpha: 2.0,
},
MetaLearningGene {
innovation_number: Arc::from("MTL01"),
learning_rate: 0.01,
learning_threshold: 0.5,
});Fields§
§neuron_id: Vec<String>§topology: Vec<TopologyGene>§neuronal_props: NeuronalPropertiesGene§meta_learning: MetaLearningGeneImplementations§
Source§impl EneCode
impl EneCode
Sourcepub fn new(
num_inputs: usize,
num_hidden: usize,
num_outputs: usize,
module: Option<&str>,
) -> Self
pub fn new( num_inputs: usize, num_hidden: usize, num_outputs: usize, module: Option<&str>, ) -> Self
Constructor function for basic genome with defined number of inputs/outputs
Sourcepub fn generate_new_topology(
input_size: usize,
output_size: usize,
num_hidden: usize,
) -> Vec<TopologyGene>
pub fn generate_new_topology( input_size: usize, output_size: usize, num_hidden: usize, ) -> Vec<TopologyGene>
Generates an appropriate Vec
Sourcepub fn new_from_genome(
topology: Vec<TopologyGene>,
neuronal_props: NeuronalPropertiesGene,
meta_learning: MetaLearningGene,
) -> Self
pub fn new_from_genome( topology: Vec<TopologyGene>, neuronal_props: NeuronalPropertiesGene, meta_learning: MetaLearningGene, ) -> Self
Constructor function for EneCode based on established genome, puts things into correct order based on NeuronType and innovation number
Sourcepub fn topology_gene(&self, neuron_id: &str) -> &TopologyGene
pub fn topology_gene(&self, neuron_id: &str) -> &TopologyGene
Trait Implementations§
Source§impl<'de> Deserialize<'de> for EneCode
impl<'de> Deserialize<'de> for EneCode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<&NeuralNetwork> for EneCode
Creates genome from neural network after recombination and mutation
impl From<&NeuralNetwork> for EneCode
Creates genome from neural network after recombination and mutation
Source§fn from(network: &NeuralNetwork) -> Self
fn from(network: &NeuralNetwork) -> Self
Source§impl PyClassImpl for EneCode
impl PyClassImpl for EneCode
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§type ThreadChecker = SendablePyClass<EneCode>
type ThreadChecker = SendablePyClass<EneCode>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyTypeInfo for EneCode
impl PyTypeInfo for EneCode
Source§type AsRefTarget = PyCell<EneCode>
type AsRefTarget = PyCell<EneCode>
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> &PyType
fn type_object(py: Python<'_>) -> &PyType
Source§fn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
object is an instance of this type or a subclass of this type.Source§fn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
object is an instance of this type.Source§impl ToPyObject for EneCode
impl ToPyObject for EneCode
impl StructuralPartialEq for EneCode
Auto Trait Implementations§
impl Freeze for EneCode
impl RefUnwindSafe for EneCode
impl Send for EneCode
impl Sync for EneCode
impl Unpin for EneCode
impl UnwindSafe for EneCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'a, T> FromPyObject<'a> for T
impl<'a, T> FromPyObject<'a> for T
Source§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.