pub struct ReLU;Expand description
Rectified Linear Unit activation: ReLU(x) = max(0, x)
§Shape
- Input:
(*)any shape - Output:
(*)same shape as input
§Example
ⓘ
use aprender::nn::{Module, ReLU};
use aprender::autograd::Tensor;
let relu = ReLU::new();
let x = Tensor::from_slice(&[-1.0, 0.0, 1.0, 2.0]);
let y = relu.forward(&x); // [0.0, 0.0, 1.0, 2.0]Implementations§
Trait Implementations§
Source§impl Module for ReLU
impl Module for ReLU
Source§fn parameters_mut(&mut self) -> Vec<&mut Tensor>
fn parameters_mut(&mut self) -> Vec<&mut Tensor>
Get mutable references to all learnable parameters. Read more
Source§fn refresh_caches(&mut self)
fn refresh_caches(&mut self)
Refresh any cached computations after parameters have been modified. Read more
Source§fn num_parameters(&self) -> usize
fn num_parameters(&self) -> usize
Get the number of learnable parameters.
impl Copy for ReLU
Auto Trait Implementations§
impl Freeze for ReLU
impl RefUnwindSafe for ReLU
impl Send for ReLU
impl Sync for ReLU
impl Unpin for ReLU
impl UnsafeUnpin for ReLU
impl UnwindSafe for ReLU
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