evonet 0.1.0a0.dev1__tar.gz → 0.1.0.dev3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/PKG-INFO +41 -5
  2. evonet-0.1.0.dev3/README.md +47 -0
  3. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/evonet/activation.py +29 -9
  4. evonet-0.1.0.dev3/evonet/connection.py +70 -0
  5. evonet-0.1.0.dev3/evonet/core.py +472 -0
  6. evonet-0.1.0.dev3/evonet/enums.py +50 -0
  7. evonet-0.1.0.dev3/evonet/layer.py +26 -0
  8. evonet-0.1.0.dev3/evonet/mutation.py +277 -0
  9. evonet-0.1.0.dev3/evonet/neuron.py +92 -0
  10. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/evonet.egg-info/PKG-INFO +41 -5
  11. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/evonet.egg-info/SOURCES.txt +5 -2
  12. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/evonet.egg-info/requires.txt +1 -0
  13. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/pyproject.toml +3 -2
  14. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/tests/test_activation.py +3 -3
  15. evonet-0.1.0.dev3/tests/test_core.py +75 -0
  16. evonet-0.1.0.dev3/tests/test_nnet_io_and_forward.py +139 -0
  17. evonet-0.1.0.dev3/tests/test_recurrent_dynamics.py +103 -0
  18. evonet-0.1.0a0.dev1/README.md +0 -12
  19. evonet-0.1.0a0.dev1/evonet/connection.py +0 -55
  20. evonet-0.1.0a0.dev1/evonet/core.py +0 -117
  21. evonet-0.1.0a0.dev1/evonet/mutation.py +0 -59
  22. evonet-0.1.0a0.dev1/evonet/neuron.py +0 -50
  23. evonet-0.1.0a0.dev1/evonet/types.py +0 -16
  24. evonet-0.1.0a0.dev1/tests/test_core.py +0 -42
  25. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/LICENSE +0 -0
  26. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/evonet/__init__.py +0 -0
  27. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/evonet/io.py +0 -0
  28. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/evonet/utils.py +0 -0
  29. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/evonet/visualize.py +0 -0
  30. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/evonet.egg-info/dependency_links.txt +0 -0
  31. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/evonet.egg-info/top_level.txt +0 -0
  32. {evonet-0.1.0a0.dev1 → evonet-0.1.0.dev3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evonet
3
- Version: 0.1.0a0.dev1
3
+ Version: 0.1.0.dev3
4
4
  Summary: Evolvable neural network core for integration with EvoLib
5
5
  Author-email: EvoLib <evolib@dismail.de>
6
6
  License: MIT License
@@ -38,6 +38,7 @@ Requires-Dist: numpy>=1.24
38
38
  Requires-Dist: pyyaml>=6.0
39
39
  Requires-Dist: pandas>=2.3.0
40
40
  Requires-Dist: pydantic<3.0,>=2.7
41
+ Requires-Dist: graphviz>=0.20.1
41
42
  Provides-Extra: dev
42
43
  Requires-Dist: mypy; extra == "dev"
43
44
  Requires-Dist: types-PyYAML; extra == "dev"
@@ -52,10 +53,45 @@ Dynamic: license-file
52
53
  [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
53
54
  [![Project Status: Alpha](https://img.shields.io/badge/status-alpha-orange.svg)](https://github.com/EvoLib/evo-net)
54
55
 
55
- **EvoNet** is a modular, evolvable neural network core designed for integration with [EvoLib](https://github.com/EvoLib/evo-lib).
56
- It supports dynamic topologies, recurrent connections, and is optimized for mutation, crossover, and structural evolution.
56
+ **EvoNet** is a modular and evolvable neural network core designed for integration with [EvoLib](https://github.com/EvoLib/evo-lib).
57
+ It supports dynamic topologies, recurrent connections, per-neuron activation, and structural evolution – with a strong emphasis on **clarity**, **transparency**, and **didactic value**.
57
58
 
58
- ## 🪪 License
59
+ ---
59
60
 
60
- This project is licensed under the [MIT License](https://github.com/EvoLib/evo-net/tree/main/LICENSE).
61
+ ## Features
62
+
63
+ - **Layer-based but flexible** – allows skip connections, cycles, and recurrent paths
64
+ - **Typed neuron roles and connection types** (`NeuronRole`, `ConnectionType`)
65
+ - **Topology-aware mutation system** – add/remove neurons and connections, mutate weights, change activations
66
+ - **Per-neuron activation functions** – configurable, extensible, evolvable
67
+ - **1-step recurrent state logic** – avoids multi-pass stabilization
68
+ - **Topology can grow at runtime** – with `add_neuron`, `add_connection`, `split_connection`
69
+ - **Debug-friendly architecture** – explicit IDs, labels, roles, directional graphs
70
+ - **Designed for evolutionary learning** – mutation, crossover, speciation ready
71
+ - **Lightweight & extensible** – pure Python, NumPy-based, no hard dependencies
72
+
73
+ ---
74
+
75
+ > ⚠️ **This project is in early development (alpha)**. Interfaces and structure may change.
76
+
77
+ ---
78
+
79
+ ## Quick Example
80
+
81
+ ```python
82
+ from evonet.core import Nnet
83
+
84
+ net = Nnet()
85
+ net.add_layer() # Input
86
+ net.add_layer() # Output
87
+
88
+ net.add_neuron(layer_idx=0, activation="linear", lable="in")
89
+ net.add_neuron(layer_idx=1, activation="linear", bias=0.5, lable="out", connect_layer=True)
90
+
91
+ print(net.calc([1.0]))
92
+ ```
93
+
94
+ ## License
95
+
96
+ MIT License - see [MIT License](https://github.com/EvoLib/evo-net/tree/main/LICENSE).
61
97
 
@@ -0,0 +1,47 @@
1
+ # EvoNet
2
+ [![Code Quality & Tests](https://github.com/EvoLib/evo-net/actions/workflows/ci.yml/badge.svg)](https://github.com/EvoLib/evo-net/actions/workflows/ci.yml)
3
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
4
+ [![Project Status: Alpha](https://img.shields.io/badge/status-alpha-orange.svg)](https://github.com/EvoLib/evo-net)
5
+
6
+ **EvoNet** is a modular and evolvable neural network core designed for integration with [EvoLib](https://github.com/EvoLib/evo-lib).
7
+ It supports dynamic topologies, recurrent connections, per-neuron activation, and structural evolution – with a strong emphasis on **clarity**, **transparency**, and **didactic value**.
8
+
9
+ ---
10
+
11
+ ## Features
12
+
13
+ - **Layer-based but flexible** – allows skip connections, cycles, and recurrent paths
14
+ - **Typed neuron roles and connection types** (`NeuronRole`, `ConnectionType`)
15
+ - **Topology-aware mutation system** – add/remove neurons and connections, mutate weights, change activations
16
+ - **Per-neuron activation functions** – configurable, extensible, evolvable
17
+ - **1-step recurrent state logic** – avoids multi-pass stabilization
18
+ - **Topology can grow at runtime** – with `add_neuron`, `add_connection`, `split_connection`
19
+ - **Debug-friendly architecture** – explicit IDs, labels, roles, directional graphs
20
+ - **Designed for evolutionary learning** – mutation, crossover, speciation ready
21
+ - **Lightweight & extensible** – pure Python, NumPy-based, no hard dependencies
22
+
23
+ ---
24
+
25
+ > ⚠️ **This project is in early development (alpha)**. Interfaces and structure may change.
26
+
27
+ ---
28
+
29
+ ## Quick Example
30
+
31
+ ```python
32
+ from evonet.core import Nnet
33
+
34
+ net = Nnet()
35
+ net.add_layer() # Input
36
+ net.add_layer() # Output
37
+
38
+ net.add_neuron(layer_idx=0, activation="linear", lable="in")
39
+ net.add_neuron(layer_idx=1, activation="linear", bias=0.5, lable="out", connect_layer=True)
40
+
41
+ print(net.calc([1.0]))
42
+ ```
43
+
44
+ ## License
45
+
46
+ MIT License - see [MIT License](https://github.com/EvoLib/evo-net/tree/main/LICENSE).
47
+
@@ -2,12 +2,13 @@
2
2
  """
3
3
  Activation functions for evolvable neural networks.
4
4
 
5
- Provides scalar functions such as ReLU, Tanh, Sigmoid, as well as a softmax
6
- implementation and a function registry (ACTIVATIONS).
5
+ Includes standard nonlinearities (ReLU, Tanh, Sigmoid), linear and threshold functions,
6
+ modern smooth activations (Swish, Mish), and a softmax utility.
7
7
 
8
- These functions are stateless and operate on scalars unless otherwise noted.
8
+ All functions are scalar-based and stateless, unless noted otherwise.
9
9
  """
10
10
 
11
+ import random
11
12
  from typing import Callable, List, Tuple, Union
12
13
 
13
14
  import numpy as np
@@ -70,7 +71,7 @@ def gaussian(x: Scalar) -> float:
70
71
  return np.exp(-(x**2))
71
72
 
72
73
 
73
- # --- Threshold Functions ---
74
+ # Threshold Functions
74
75
 
75
76
 
76
77
  def binary(x: Scalar) -> float:
@@ -83,7 +84,7 @@ def signum(x: Scalar) -> float:
83
84
  return 1.0 if x > 0 else -1.0 if x < 0 else 0.0
84
85
 
85
86
 
86
- # --- Linear Variants ---
87
+ # Linear Variants
87
88
 
88
89
 
89
90
  def linear(x: Scalar) -> float:
@@ -154,13 +155,32 @@ def softmax(values: Union[List[float], Tuple[float], np.ndarray]) -> np.ndarray:
154
155
  return exp_x / np.sum(exp_x)
155
156
 
156
157
 
157
- # --- Registry ---
158
+ def random_function_name(activations: list[str] | None = None) -> str:
159
+ """
160
+ Return a random activation function name from the registry.
161
+
162
+ Args:
163
+ activations (list[str] | None): Optional subset of allowed function names.
164
+ If None, all registered activation names are considered.
165
+
166
+ Raises:
167
+ ValueError: If any name is not in the activation registry.
168
+
169
+ Returns:
170
+ str: Randomly selected activation function name.
171
+ """
172
+
173
+ if activations is None:
174
+ activations = list(ACTIVATIONS.keys())
175
+
176
+ invalid = set(activations) - set(ACTIVATIONS.keys())
177
+ if invalid:
178
+ raise ValueError(f"Invalid activation functions: {invalid}")
158
179
 
180
+ return random.choice(activations)
159
181
 
160
- def random_function() -> str:
161
- """Returns a random activation function name from the registry."""
162
- return np.random.choice(list(ACTIVATIONS.keys()))
163
182
 
183
+ # Registry
164
184
 
165
185
  ACTIVATIONS: dict[str, Callable] = {
166
186
  "tanh": tanh,
@@ -0,0 +1,70 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """
3
+ Connection between neurons in an evolvable neural network.
4
+
5
+ A connection links a source neuron to a target neuron and transmits a weighted signal.
6
+ Supports optional connection types for specialized behaviors (e.g. inhibitory,
7
+ recurrent).
8
+ """
9
+
10
+
11
+ from typing import TYPE_CHECKING
12
+
13
+ from evonet.enums import ConnectionType
14
+
15
+ if TYPE_CHECKING:
16
+ from evonet.neuron import Neuron
17
+
18
+
19
+ class Connection:
20
+ """
21
+ Represents a directed, weighted connection between two neurons.
22
+
23
+ Attributes:
24
+ source (Neuron): The source neuron (presynaptic).
25
+ target (Neuron): The target neuron (postsynaptic).
26
+ weight (float): Multiplicative weight of the transmitted signal.
27
+ delay (int): Optional delay in time steps (not yet implemented).
28
+ type (ConnectionType): Type of connection (e.g. standard, recurrent,
29
+ inhibitory).
30
+ """
31
+
32
+ def __init__(
33
+ self,
34
+ source: "Neuron",
35
+ target: "Neuron",
36
+ weight: float = 1.0,
37
+ delay: int = 0,
38
+ conn_type: ConnectionType = ConnectionType.STANDARD,
39
+ ) -> None:
40
+
41
+ self.source = source
42
+ self.target = target
43
+ self.weight = weight
44
+ self.delay = delay
45
+ self.type: ConnectionType = conn_type
46
+
47
+ def get_signal(self) -> float:
48
+ """
49
+ Return the weighted signal from the source neuron.
50
+
51
+ Returns:
52
+ float: source.output × weight
53
+ """
54
+
55
+ return self.source.output * self.weight
56
+
57
+ def __repr__(self) -> str:
58
+ """
59
+ Return a concise string representation of the connection.
60
+
61
+ Example:
62
+ <Conn abc123 -> def456 w=0.85 type=standard>
63
+ """
64
+
65
+ type_str = self.type.name.lower()
66
+ return (
67
+ f"<Conn {self.source.id[:6]} "
68
+ f"-> {self.target.id[:6]} "
69
+ f"w={self.weight:.2f} type={type_str}>"
70
+ )