pub struct EncoderDecoderTransformer<T: FloatBounds> { /* private fields */ }Expand description
Complete Encoder-Decoder Transformer
Implementations§
Source§impl<T: FloatBounds + ScalarOperand + From<f64>> EncoderDecoderTransformer<T>
impl<T: FloatBounds + ScalarOperand + From<f64>> EncoderDecoderTransformer<T>
Sourcepub fn new(config: TransformerConfig<T>) -> NeuralResult<Self>
pub fn new(config: TransformerConfig<T>) -> NeuralResult<Self>
Create a new encoder-decoder transformer
Sourcepub fn forward(
&mut self,
src_ids: &Array2<usize>,
tgt_ids: &Array2<usize>,
src_mask: Option<&Array2<bool>>,
tgt_mask: Option<&Array2<bool>>,
cross_mask: Option<&Array2<bool>>,
training: bool,
) -> NeuralResult<Array3<T>>
pub fn forward( &mut self, src_ids: &Array2<usize>, tgt_ids: &Array2<usize>, src_mask: Option<&Array2<bool>>, tgt_mask: Option<&Array2<bool>>, cross_mask: Option<&Array2<bool>>, training: bool, ) -> NeuralResult<Array3<T>>
Forward pass for training
Sourcepub fn generate(
&mut self,
src_ids: &Array2<usize>,
max_length: usize,
start_token: usize,
end_token: usize,
src_mask: Option<&Array2<bool>>,
) -> NeuralResult<Array2<usize>>
pub fn generate( &mut self, src_ids: &Array2<usize>, max_length: usize, start_token: usize, end_token: usize, src_mask: Option<&Array2<bool>>, ) -> NeuralResult<Array2<usize>>
Generate sequences auto-regressively
Sourcepub fn config(&self) -> &TransformerConfig<T>
pub fn config(&self) -> &TransformerConfig<T>
Get configuration
Trait Implementations§
Source§impl<T: Clone + FloatBounds> Clone for EncoderDecoderTransformer<T>
impl<T: Clone + FloatBounds> Clone for EncoderDecoderTransformer<T>
Source§fn clone(&self) -> EncoderDecoderTransformer<T>
fn clone(&self) -> EncoderDecoderTransformer<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for EncoderDecoderTransformer<T>where
T: Freeze,
impl<T> RefUnwindSafe for EncoderDecoderTransformer<T>where
T: RefUnwindSafe,
impl<T> Send for EncoderDecoderTransformer<T>
impl<T> Sync for EncoderDecoderTransformer<T>
impl<T> Unpin for EncoderDecoderTransformer<T>where
T: Unpin,
impl<T> UnsafeUnpin for EncoderDecoderTransformer<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for EncoderDecoderTransformer<T>where
T: UnwindSafe + RefUnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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