From 1f0bf3bea145271bbc3bf970eee3254e43a8eeed Mon Sep 17 00:00:00 2001 From: Tristan Murphy <72839119+inflectrix@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:54:58 +0000 Subject: [PATCH] fix topology index error (runnable still an issue) --- src/topology.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/topology.rs b/src/topology.rs index b5ae19a..4f4e7f7 100644 --- a/src/topology.rs +++ b/src/topology.rs @@ -138,6 +138,30 @@ impl NeuralNetworkTopology { } } } + + fn deletion_shift(&self, deleted: NeuronLocation) { + if !deleted.is_hidden() { + panic!("Invalid neuron deletion"); + } + + for n in &self.hidden_layers { + let mut nw = n.write().unwrap(); + for (loc, _w) in &mut nw.inputs { + if loc.is_hidden() && loc.unwrap() > deleted.unwrap() { + *loc = NeuronLocation::Hidden(loc.unwrap() - 1); + } + } + } + + for n in &self.output_layer { + let mut nw = n.write().unwrap(); + for (loc, _w) in &mut nw.inputs { + if loc.is_hidden() && loc.unwrap() > deleted.unwrap() { + *loc = NeuronLocation::Hidden(loc.unwrap() - 1); + } + } + } + } } // need to do all this manually because Arcs are cringe @@ -252,6 +276,8 @@ impl RandomlyMutable for NeuralNetworkTopology() <= rate {