pub struct LinearTransformerBase<A: LinearAttentionLike> {
pub d_in: usize,
pub attn: A,
pub norm_attn: LayerNorm,
pub feed_forward: PositionwiseFFN,
pub norm_feed_forward: LayerNorm,
}Fields§
§d_in: usize§attn: A§norm_attn: LayerNorm§feed_forward: PositionwiseFFN§norm_feed_forward: LayerNormImplementations§
Source§impl<A: LinearAttentionLike> LinearTransformerBase<A>
impl<A: LinearAttentionLike> LinearTransformerBase<A>
pub fn new(d_in: usize, d_head: usize) -> Self
pub fn from_attn(d_in: usize, attn: A) -> Self
pub fn forward(&mut self, x: Array3<f32>, grad: bool) -> Array3<f32>
pub fn new_state(&self, batch_size: usize) -> Array3<f32>
pub fn step(&self, x: &Array2<f32>, state: &mut Array3<f32>) -> Array2<f32>
pub fn backward(&mut self, d_loss: Array3<f32>) -> Array3<f32>
Trait Implementations§
Source§impl<A: Clone + LinearAttentionLike> Clone for LinearTransformerBase<A>
impl<A: Clone + LinearAttentionLike> Clone for LinearTransformerBase<A>
Source§impl<A: Debug + LinearAttentionLike> Debug for LinearTransformerBase<A>
impl<A: Debug + LinearAttentionLike> Debug for LinearTransformerBase<A>
Source§impl<'de, A> Deserialize<'de> for LinearTransformerBase<A>where
A: Deserialize<'de> + LinearAttentionLike,
impl<'de, A> Deserialize<'de> for LinearTransformerBase<A>where
A: Deserialize<'de> + LinearAttentionLike,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<A> Serialize for LinearTransformerBase<A>where
A: Serialize + LinearAttentionLike,
impl<A> Serialize for LinearTransformerBase<A>where
A: Serialize + LinearAttentionLike,
Source§impl<A: LinearAttentionLike> ToIntermediates for LinearTransformerBase<A>
impl<A: LinearAttentionLike> ToIntermediates for LinearTransformerBase<A>
fn intermediates(&mut self) -> Vec<&mut dyn Intermediate>
fn stash_intermediates(&mut self) -> Vec<ArrayD<f32>>
fn apply_intermediates(&mut self, intermediates_b: Vec<ArrayD<f32>>)
Source§impl<A: LinearAttentionLike> ToParams for LinearTransformerBase<A>
impl<A: LinearAttentionLike> ToParams for LinearTransformerBase<A>
fn params(&mut self) -> Vec<Param>
fn zero_grads(&mut self)
fn dump(&mut self) -> Vec<TensorData>
fn load(&mut self, params: Vec<TensorData>)
fn persist(&mut self, path: &str) -> Result<(), Box<dyn Error>>
fn restore(&mut self, path: &str) -> Result<(), Box<dyn Error>>
Auto Trait Implementations§
impl<A> Forget for LinearTransformerBase<A>
impl<A> Freeze for LinearTransformerBase<A>where
A: Freeze,
impl<A> Move for LinearTransformerBase<A>
impl<A> RefUnwindSafe for LinearTransformerBase<A>where
A: RefUnwindSafe,
impl<A> Send for LinearTransformerBase<A>where
A: Send,
impl<A> Sync for LinearTransformerBase<A>where
A: Sync,
impl<A> Unpin for LinearTransformerBase<A>where
A: Unpin,
impl<A> UnsafeUnpin for LinearTransformerBase<A>where
A: UnsafeUnpin,
impl<A> UnwindSafe for LinearTransformerBase<A>where
A: UnwindSafe,
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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