Skip to content

Commit 1ca896b

Browse files
authored
Merge pull request #62 from HyperCodec/duped-inputs
Prevent duplicated neuron inputs
2 parents 9c4daf4 + e45908c commit 1ca896b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/topology/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ impl<const I: usize, const O: usize> NeuralNetworkTopology<I, O> {
121121
return true;
122122
}
123123

124+
// check to make sure it isn't duplicate
125+
{
126+
let n = self.get_neuron(to);
127+
let n2 = n.read().unwrap();
128+
129+
for (loc, _) in &n2.inputs {
130+
if from == *loc {
131+
return false;
132+
}
133+
}
134+
}
135+
124136
let mut visited = HashSet::new();
125137
self.dfs(from, to, &mut visited)
126138
}

0 commit comments

Comments
 (0)