pub struct OutputProjection<T: Float + Debug + Send + Sync + 'static> { /* private fields */ }Expand description
Output projection for generating parameter updates
Implementations§
Source§impl<T: Float + Debug + Send + Sync + 'static> OutputProjection<T>
impl<T: Float + Debug + Send + Sync + 'static> OutputProjection<T>
Sourcepub fn weight_snapshot(&self) -> &Array2<T>
pub fn weight_snapshot(&self) -> &Array2<T>
The projection matrix, shaped (output_size, input_size).
Sourcepub fn bias_snapshot(&self) -> &Array1<T>
pub fn bias_snapshot(&self) -> &Array1<T>
The projection bias, length output_size.
Source§impl<T: Float + Debug + Send + Sync + 'static + Default + Clone> OutputProjection<T>
impl<T: Float + Debug + Send + Sync + 'static + Default + Clone> OutputProjection<T>
Sourcepub fn new(
input_size: usize,
output_size: usize,
output_transform: OutputTransform,
) -> Result<Self>
pub fn new( input_size: usize, output_size: usize, output_transform: OutputTransform, ) -> Result<Self>
Create a new output projection with Xavier-initialized weights.
The output-side transform (tanh / scaling / …) named by
output_transform is applied by the caller (see
LSTMOptimizer::generate_updates); this projection itself computes the
underlying linear map W x + b.
Sourcepub fn forward(&self, input: &Array1<T>) -> Result<Array1<T>>
pub fn forward(&self, input: &Array1<T>) -> Result<Array1<T>>
Forward pass through output projection: output = W * input + b.
Sourcepub fn reset(&mut self, input_size: usize, output_size: usize)
pub fn reset(&mut self, input_size: usize, output_size: usize)
Re-randomize the projection weights and zero the bias.
Used when the target output dimension changes at runtime (e.g. the
flattened parameter count the optimizer is asked to update does not
match this projection’s configured output_features): a fresh Xavier
draw at the new shape is the honest response, since there is no
meaningful way to reuse weights trained for a different output size.
Sourcepub fn output_size(&self) -> usize
pub fn output_size(&self) -> usize
Current output dimension.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for OutputProjection<T>
impl<T> RefUnwindSafe for OutputProjection<T>
impl<T> Send for OutputProjection<T>
impl<T> Sync for OutputProjection<T>
impl<T> Unpin for OutputProjection<T>
impl<T> UnsafeUnpin for OutputProjection<T>
impl<T> UnwindSafe for OutputProjection<T>
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
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> ⓘ
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> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.