pub struct LeCun;Expand description
LeCun’s tanh activation function.
This activation function is defined as:
f(x) = 1.7159 * tanh(0.666 * x)
It provides a smoother alternative to standard tanh with better gradient flow properties. The scaling factors (1.7159 and 0.666) are chosen such that:
- The function approximates the identity near the origin
- The output range is approximately [-1.7159, 1.7159]
§Example
use burn::backend::NdArray;
use burn::tensor::Tensor;
use ncps::activation::LeCun;
type Backend = NdArray<f32>;
let device = Default::default();
let x = Tensor::<Backend, 1>::from_floats([0.0, 1.0, -1.0], &device);
let y = LeCun::forward(x);Implementations§
Auto Trait Implementations§
impl Freeze for LeCun
impl RefUnwindSafe for LeCun
impl Send for LeCun
impl Sync for LeCun
impl Unpin for LeCun
impl UnwindSafe for LeCun
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> 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