pub enum Activation {
Identity,
ReLU,
Tanh,
}Expand description
Element-wise activation applied at the output of a DenseLayer.
Kept intentionally small for the v0.2.0 preview: Identity (no-op, for
the terminal layer or for identity-MLP test fixtures), ReLU, and
Tanh. Any more exotic activation (GELU, Swish, etc.) is a deliberate
non-goal for this release.
Variants§
Implementations§
Source§impl Activation
impl Activation
Sourcepub fn apply_inplace(&self, values: &mut [f64])
pub fn apply_inplace(&self, values: &mut [f64])
Apply the activation element-wise in place.
Sourcepub fn apply_scalar(&self, v: f64) -> f64
pub fn apply_scalar(&self, v: f64) -> f64
Apply the activation element-wise to a single scalar.
Sourcepub fn derivative(&self, pre_activation: f64) -> f64
pub fn derivative(&self, pre_activation: f64) -> f64
Derivative f'(z) evaluated at the pre-activation z. Used by
the analytical gradient paths in
crate::deep_kernel::gradient.
For ReLU we follow the common convention f'(0) = 0 — this is a
sub-gradient (any value in [0, 1] is admissible), but 0 is the
widely adopted choice that matches finite-difference tests at most
random initialisations.
Trait Implementations§
Source§impl Clone for Activation
impl Clone for Activation
Source§fn clone(&self) -> Activation
fn clone(&self) -> Activation
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Activation
impl Debug for Activation
Source§impl Hash for Activation
impl Hash for Activation
Source§impl PartialEq for Activation
impl PartialEq for Activation
impl Copy for Activation
impl Eq for Activation
impl StructuralPartialEq for Activation
Auto Trait Implementations§
impl Freeze for Activation
impl RefUnwindSafe for Activation
impl Send for Activation
impl Sync for Activation
impl Unpin for Activation
impl UnsafeUnpin for Activation
impl UnwindSafe for Activation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more