Struct dfdx::nn::GeneralizedResidual
source · [−]pub struct GeneralizedResidual<F, R> {
pub f: F,
pub r: R,
}
Expand description
A residual connection R
around F
: F(x) + R(x)
,
as introduced in Deep Residual Learning for Image Recognition.
Generics
F
: The underlying module to do a skip connection around.R
: The underlying residual module
Examples
let module: GeneralizedResidual<ReLU, Square> = Default::default();
let x = Tensor1D::new([-2.0, -1.0, 0.0, 1.0, 2.0]);
let y = module.forward(x);
assert_eq!(y.data(), &[4.0, 1.0, 0.0, 2.0, 6.0]);
Fields
f: F
r: R
Trait Implementations
sourceimpl<F: CanUpdateWithGradients, R: CanUpdateWithGradients> CanUpdateWithGradients for GeneralizedResidual<F, R>
impl<F: CanUpdateWithGradients, R: CanUpdateWithGradients> CanUpdateWithGradients for GeneralizedResidual<F, R>
sourcefn update<G: GradientProvider>(
&mut self,
grads: &mut G,
unused: &mut UnusedTensors
)
fn update<G: GradientProvider>(
&mut self,
grads: &mut G,
unused: &mut UnusedTensors
)
Pass through to F
’s CanUpdateWithGradients.
sourceimpl<F: Clone, R: Clone> Clone for GeneralizedResidual<F, R>
impl<F: Clone, R: Clone> Clone for GeneralizedResidual<F, R>
sourcefn clone(&self) -> GeneralizedResidual<F, R>
fn clone(&self) -> GeneralizedResidual<F, R>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl<F: Debug, R: Debug> Debug for GeneralizedResidual<F, R>
impl<F: Debug, R: Debug> Debug for GeneralizedResidual<F, R>
sourceimpl<F: Default, R: Default> Default for GeneralizedResidual<F, R>
impl<F: Default, R: Default> Default for GeneralizedResidual<F, R>
sourcefn default() -> GeneralizedResidual<F, R>
fn default() -> GeneralizedResidual<F, R>
Returns the “default value” for a type. Read more
sourceimpl<F: LoadFromNpz, R: LoadFromNpz> LoadFromNpz for GeneralizedResidual<F, R>
impl<F: LoadFromNpz, R: LoadFromNpz> LoadFromNpz for GeneralizedResidual<F, R>
sourceimpl<F, R, T> Module<T> for GeneralizedResidual<F, R>where
T: Tensor<Dtype = f32>,
F: Module<T>,
R: Module<T, Output = F::Output>,
F::Output: Tensor<Dtype = f32, Tape = T::Tape>,
impl<F, R, T> Module<T> for GeneralizedResidual<F, R>where
T: Tensor<Dtype = f32>,
F: Module<T>,
R: Module<T, Output = F::Output>,
F::Output: Tensor<Dtype = f32, Tape = T::Tape>,
sourceimpl<F, R, T> ModuleMut<T> for GeneralizedResidual<F, R>where
T: Tensor<Dtype = f32>,
F: ModuleMut<T>,
R: ModuleMut<T, Output = F::Output>,
F::Output: Tensor<Dtype = f32, Tape = T::Tape>,
impl<F, R, T> ModuleMut<T> for GeneralizedResidual<F, R>where
T: Tensor<Dtype = f32>,
F: ModuleMut<T>,
R: ModuleMut<T, Output = F::Output>,
F::Output: Tensor<Dtype = f32, Tape = T::Tape>,
sourcefn forward_mut(&mut self, x: T) -> Self::Output
fn forward_mut(&mut self, x: T) -> Self::Output
sourceimpl<F: ResetParams, R: ResetParams> ResetParams for GeneralizedResidual<F, R>
impl<F: ResetParams, R: ResetParams> ResetParams for GeneralizedResidual<F, R>
sourcefn reset_params<RNG: Rng>(&mut self, rng: &mut RNG)
fn reset_params<RNG: Rng>(&mut self, rng: &mut RNG)
Pass through to F
’s ResetParams.
Auto Trait Implementations
impl<F, R> RefUnwindSafe for GeneralizedResidual<F, R>where
F: RefUnwindSafe,
R: RefUnwindSafe,
impl<F, R> Send for GeneralizedResidual<F, R>where
F: Send,
R: Send,
impl<F, R> Sync for GeneralizedResidual<F, R>where
F: Sync,
R: Sync,
impl<F, R> Unpin for GeneralizedResidual<F, R>where
F: Unpin,
R: Unpin,
impl<F, R> UnwindSafe for GeneralizedResidual<F, R>where
F: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more