evonet 0.1.0.dev19__tar.gz → 0.1.0.dev21__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.
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/PKG-INFO +1 -1
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/mutation.py +3 -54
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet.egg-info/PKG-INFO +1 -1
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/pyproject.toml +1 -1
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/LICENSE +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/README.md +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/__init__.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/activation.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/connection.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/core.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/core_mit_plot_simple.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/enums.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/io.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/layer.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/neuron.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/serialization.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/utils.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet/visualize.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet.egg-info/SOURCES.txt +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet.egg-info/dependency_links.txt +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet.egg-info/requires.txt +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/evonet.egg-info/top_level.txt +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/setup.cfg +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/tests/test_activation.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/tests/test_core.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/tests/test_nnet_io_and_forward.py +0 -0
- {evonet-0.1.0.dev19 → evonet-0.1.0.dev21}/tests/test_recurrent_dynamics.py +0 -0
|
@@ -312,7 +312,7 @@ def add_random_neuron(
|
|
|
312
312
|
return new_neuron
|
|
313
313
|
|
|
314
314
|
|
|
315
|
-
def remove_random_neuron(net: Nnet) ->
|
|
315
|
+
def remove_random_neuron(net: Nnet) -> bool:
|
|
316
316
|
"""
|
|
317
317
|
Remove a randomly selected hidden neuron from the network.
|
|
318
318
|
|
|
@@ -320,7 +320,7 @@ def remove_random_neuron(net: Nnet) -> None:
|
|
|
320
320
|
"""
|
|
321
321
|
hidden_neurons = [n for n in net.get_all_neurons() if n.role == NeuronRole.HIDDEN]
|
|
322
322
|
if not hidden_neurons:
|
|
323
|
-
return
|
|
323
|
+
return False
|
|
324
324
|
|
|
325
325
|
neuron = random.choice(hidden_neurons)
|
|
326
326
|
|
|
@@ -336,55 +336,4 @@ def remove_random_neuron(net: Nnet) -> None:
|
|
|
336
336
|
layer.neurons.remove(neuron)
|
|
337
337
|
break
|
|
338
338
|
|
|
339
|
-
|
|
340
|
-
def split_connection(
|
|
341
|
-
net: Nnet, activation: str = "tanh", noise: float = 0.1
|
|
342
|
-
) -> Neuron | None:
|
|
343
|
-
"""
|
|
344
|
-
Insert a neuron in the middle of an existing connection.
|
|
345
|
-
|
|
346
|
-
The old connection is removed, and two new ones are created:
|
|
347
|
-
- from source → new neuron
|
|
348
|
-
- from new neuron → target
|
|
349
|
-
|
|
350
|
-
Args:
|
|
351
|
-
net (Nnet): The target network.
|
|
352
|
-
activation (str): Activation function for the new neuron.
|
|
353
|
-
noise (float): Optional noise applied to new weights.
|
|
354
|
-
|
|
355
|
-
Returns:
|
|
356
|
-
Neuron: Added neuron, or None
|
|
357
|
-
"""
|
|
358
|
-
|
|
359
|
-
all_connections = net.get_all_connections()
|
|
360
|
-
if not all_connections:
|
|
361
|
-
return None
|
|
362
|
-
|
|
363
|
-
conn = random.choice(all_connections)
|
|
364
|
-
src, dst = conn.source, conn.target
|
|
365
|
-
|
|
366
|
-
insert_idx = None
|
|
367
|
-
for idx, layer in enumerate(net.layers):
|
|
368
|
-
if src in layer.neurons:
|
|
369
|
-
insert_idx = idx + 1
|
|
370
|
-
break
|
|
371
|
-
|
|
372
|
-
if insert_idx is None or insert_idx >= len(net.layers):
|
|
373
|
-
return None
|
|
374
|
-
|
|
375
|
-
new_neuron = net.add_neuron(
|
|
376
|
-
layer_idx=insert_idx,
|
|
377
|
-
role=NeuronRole.HIDDEN,
|
|
378
|
-
activation=activation,
|
|
379
|
-
connection_init="none",
|
|
380
|
-
)[0]
|
|
381
|
-
|
|
382
|
-
# Set new connections
|
|
383
|
-
src.outgoing.remove(conn)
|
|
384
|
-
dst.incoming.remove(conn)
|
|
385
|
-
|
|
386
|
-
weight = 1.0 + np.random.normal(0, noise)
|
|
387
|
-
net.add_connection(src, new_neuron, weight=weight)
|
|
388
|
-
net.add_connection(new_neuron, dst, weight=conn.weight)
|
|
389
|
-
|
|
390
|
-
return new_neuron
|
|
339
|
+
return True
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|