Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing mutations #13

Merged
merged 11 commits into from
Feb 20, 2024
Prev Previous commit
Next Next commit
fix remaining subtraction/index errors
  • Loading branch information
HyperCodec committed Feb 16, 2024
commit e821cfb5b8d0a4951e70cdc4e424f08124240eb2
18 changes: 11 additions & 7 deletions src/topology.rs
Original file line number Diff line number Diff line change
@@ -124,11 +124,7 @@ impl<const I: usize, const O: usize> NeuralNetworkTopology<I, O> {
let i = rng.gen_range(0..self.input_layer.len());
(self.input_layer[i].clone(), NeuronLocation::Input(i))
}
1 => {
if self.hidden_layers.is_empty() {
return self.rand_neuron(rng);
}

1 if !self.hidden_layers.is_empty() => {
let i = rng.gen_range(0..self.hidden_layers.len());
(self.hidden_layers[i].clone(), NeuronLocation::Hidden(i))
}
@@ -161,7 +157,11 @@ impl<const I: usize, const O: usize> NeuralNetworkTopology<I, O> {
return None;
}

Some((NeuronLocation::Hidden(input_loc.unwrap() - 1), w))
if input_loc.unwrap() > index {
return Some((NeuronLocation::Hidden(input_loc.unwrap() - 1), w));
}

Some((input_loc, w))
})
.collect();
}
@@ -179,7 +179,11 @@ impl<const I: usize, const O: usize> NeuralNetworkTopology<I, O> {
return None;
}

Some((NeuronLocation::Hidden(input_loc.unwrap() - 1), w)) // TODO fix attempt to subtract with overflow (no idea)
if input_loc.unwrap() > index {
return Some((NeuronLocation::Hidden(input_loc.unwrap() - 1), w));
}

Some((input_loc, w))
})
.collect();
}