Skip to content

Commit

Permalink
solve errors with activations_in_scope
Browse files Browse the repository at this point in the history
  • Loading branch information
HyperCodec committed Apr 16, 2024
1 parent 3e556d1 commit aee433f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/topology/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl ActivationRegistry {
}
}

/// Gets a Vec of all the
/// Gets a Vec of all the activation functions registered. Unless you need an owned value, use [fns][ActivationRegistry::fns].values() instead.
pub fn activations(&self) -> Vec<ActivationFn> {
self.fns.values().cloned().collect()
}
Expand All @@ -77,7 +77,9 @@ impl ActivationRegistry {
let acts = self.activations();

acts.into_iter()
.filter(|a| !scope.contains(ActivationScope::NONE) && scope.contains(a.scope))
.filter(|a| {
a.scope != ActivationScope::NONE && a.scope.contains(scope)
})
.collect()
}
}
Expand All @@ -101,7 +103,7 @@ impl Default for ActivationRegistry {

bitflags! {
/// Specifies where an activation function can occur
#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct ActivationScope: u8 {
/// Whether the activation can be applied to the input layer.
const INPUT = 0b001;
Expand All @@ -112,8 +114,8 @@ bitflags! {
/// Whether the activation can be applied to the output layer.
const OUTPUT = 0b100;

/// If this flag is true, it ignores all the rest and does not make the function naturally occur.
const NONE = 0b1000;
/// The activation function will not be randomly placed anywhere
const NONE = 0b000;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/topology/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ impl NeuronTopology {
) -> Self {
let mut activations: Vec<_> = activations.into_iter().collect();



Self::new_with_activation(
inputs,
activations.remove(rng.gen_range(0..activations.len())),
Expand Down

0 comments on commit aee433f

Please sign in to comment.