pub enum LayerOutput {
Embedding(Tensor),
EncoderWithAttention(HiddenLayer),
}Expand description
Output of a BERT layer.
Variants§
Implementations§
Source§impl LayerOutput
impl LayerOutput
Sourcepub fn attention(&self) -> Option<&Tensor>
pub fn attention(&self) -> Option<&Tensor>
Get the layer attention.
Return a Some value if the layer output is from an encoder layer,
or None otherwise.
Sourcepub fn embedding(&self) -> Option<&Tensor>
pub fn embedding(&self) -> Option<&Tensor>
Get the embedding.
Returns Some if the layer output is an embedding or None
otherwise.
Sourcepub fn map_output<F>(&self, f: F) -> Result<Self, TransformerError>
pub fn map_output<F>(&self, f: F) -> Result<Self, TransformerError>
Map the output representation of this layer.
Sourcepub fn output_mut(&mut self) -> &mut Tensor
pub fn output_mut(&mut self) -> &mut Tensor
Get the layer output mutably.
Sourcepub fn encoder_with_attention(&self) -> Option<&HiddenLayer>
pub fn encoder_with_attention(&self) -> Option<&HiddenLayer>
Get the output of an encoder layer.
Return a Some value if the layer output is from an encoder layer,
or None otherwise.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LayerOutput
impl RefUnwindSafe for LayerOutput
impl Send for LayerOutput
impl !Sync for LayerOutput
impl Unpin for LayerOutput
impl UnwindSafe for LayerOutput
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