pub struct ScalarWeight { /* private fields */ }Expand description
Layer that performs a scalar weighting of layers.
Following Peters et al., 2018 and Kondratyuk & Straka, 2019, this layer applies scalar weighting:
e = c ∑_i[ h_i · softmax(w)_i ]
Implementations§
Source§impl ScalarWeight
impl ScalarWeight
pub fn new<'a>( vs: impl Borrow<PathExt<'a>>, n_layers: i64, layer_dropout_prob: f64, ) -> Result<Self, TransformerError>
pub fn forward( &self, layers: &[LayerOutput], train: bool, ) -> Result<Tensor, TransformerError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ScalarWeight
impl RefUnwindSafe for ScalarWeight
impl Send for ScalarWeight
impl !Sync for ScalarWeight
impl Unpin for ScalarWeight
impl UnwindSafe for ScalarWeight
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