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
sourceimpl 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 RefUnwindSafe for ScalarWeight
impl Send for ScalarWeight
impl !Sync for ScalarWeight
impl Unpin for ScalarWeight
impl UnwindSafe for ScalarWeight
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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