pub struct TransformerOptimizerState<T: Float + Debug + ScalarOperand + Send + Sync + 'static> {
pub current_parameters: Array1<T>,
/* private fields */
}Expand description
Transformer optimizer state
Fields§
§current_parameters: Array1<T>Current model parameters
Implementations§
Source§impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> TransformerOptimizerState<T>
impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> TransformerOptimizerState<T>
Sourcepub fn new(config: &TransformerBasedOptimizerConfig<T>) -> Result<Self>
pub fn new(config: &TransformerBasedOptimizerConfig<T>) -> Result<Self>
Create new optimizer state
Sourcepub fn update_with_step(
&mut self,
update: &Array1<T>,
loss: Option<T>,
) -> Result<()>
pub fn update_with_step( &mut self, update: &Array1<T>, loss: Option<T>, ) -> Result<()>
Update state with optimization step.
update need not already match current_parameters’s length: the
meta-learned update network produces one “layer’s worth” of update
(model_dimension elements), which is applied identically to every
transformer-layer segment of the (model_dimension * num_transformer_layers)-sized parameter vector. See
Self::project_update.
Sourcepub fn create_snapshot(&self) -> Result<OptimizerStateSnapshot<T>>
pub fn create_snapshot(&self) -> Result<OptimizerStateSnapshot<T>>
Create state snapshot
Sourcepub fn restore_from_snapshot(
&mut self,
snapshot: &OptimizerStateSnapshot<T>,
) -> Result<()>
pub fn restore_from_snapshot( &mut self, snapshot: &OptimizerStateSnapshot<T>, ) -> Result<()>
Restore from snapshot
Sourcepub fn save_checkpoint(&mut self, name: String) -> Result<String>
pub fn save_checkpoint(&mut self, name: String) -> Result<String>
Save checkpoint
Sourcepub fn load_checkpoint(&mut self, checkpoint_id: &str) -> Result<()>
pub fn load_checkpoint(&mut self, checkpoint_id: &str) -> Result<()>
Load checkpoint
Sourcepub fn get_parameter_stats(&self) -> ParameterStatistics<T>
pub fn get_parameter_stats(&self) -> ParameterStatistics<T>
Get parameter statistics
Sourcepub fn get_optimization_progress(&self) -> OptimizationProgress<T>
pub fn get_optimization_progress(&self) -> OptimizationProgress<T>
Get optimization progress
Sourcepub fn get_learning_stats(&self) -> LearningStatistics<T>
pub fn get_learning_stats(&self) -> LearningStatistics<T>
Get learning statistics
Sourcepub fn validate_state(&self) -> Result<StateValidationReport>
pub fn validate_state(&self) -> Result<StateValidationReport>
Validate state consistency
Sourcepub fn get_state_summary(&self) -> StateSummary<T>
pub fn get_state_summary(&self) -> StateSummary<T>
Get state summary
Sourcepub fn get_metadata(&self) -> StateMetadata
pub fn get_metadata(&self) -> StateMetadata
Get state metadata
Sourcepub fn export_state(&self) -> Result<SerializableState<T>>
pub fn export_state(&self) -> Result<SerializableState<T>>
Export state to serializable format
Sourcepub fn import_state(&mut self, state: SerializableState<T>) -> Result<()>
pub fn import_state(&mut self, state: SerializableState<T>) -> Result<()>
Import state from serializable format
Auto Trait Implementations§
impl<T> Freeze for TransformerOptimizerState<T>where
ArrayBase<OwnedRepr<T>, Dim<[usize; 1]>>: Freeze,
ParameterHistory<T>: Freeze,
OptimizationState<T>: Freeze,
LearningState<T>: Freeze,
MemoryState<T>: Freeze,
CheckpointManager<T>: Freeze,
StateStatistics<T>: Freeze,
impl<T> RefUnwindSafe for TransformerOptimizerState<T>where
ArrayBase<OwnedRepr<T>, Dim<[usize; 1]>>: RefUnwindSafe,
ParameterHistory<T>: RefUnwindSafe,
OptimizationState<T>: RefUnwindSafe,
LearningState<T>: RefUnwindSafe,
MemoryState<T>: RefUnwindSafe,
CheckpointManager<T>: RefUnwindSafe,
StateStatistics<T>: RefUnwindSafe,
impl<T> Send for TransformerOptimizerState<T>where
ArrayBase<OwnedRepr<T>, Dim<[usize; 1]>>: Send,
ParameterHistory<T>: Send,
OptimizationState<T>: Send,
LearningState<T>: Send,
MemoryState<T>: Send,
CheckpointManager<T>: Send,
StateStatistics<T>: Send,
impl<T> Sync for TransformerOptimizerState<T>where
ArrayBase<OwnedRepr<T>, Dim<[usize; 1]>>: Sync,
ParameterHistory<T>: Sync,
OptimizationState<T>: Sync,
LearningState<T>: Sync,
MemoryState<T>: Sync,
CheckpointManager<T>: Sync,
StateStatistics<T>: Sync,
impl<T> Unpin for TransformerOptimizerState<T>where
ArrayBase<OwnedRepr<T>, Dim<[usize; 1]>>: Unpin,
ParameterHistory<T>: Unpin,
OptimizationState<T>: Unpin,
LearningState<T>: Unpin,
MemoryState<T>: Unpin,
CheckpointManager<T>: Unpin,
StateStatistics<T>: Unpin,
impl<T> UnsafeUnpin for TransformerOptimizerState<T>where
ArrayBase<OwnedRepr<T>, Dim<[usize; 1]>>: UnsafeUnpin,
ParameterHistory<T>: UnsafeUnpin,
OptimizationState<T>: UnsafeUnpin,
LearningState<T>: UnsafeUnpin,
MemoryState<T>: UnsafeUnpin,
CheckpointManager<T>: UnsafeUnpin,
StateStatistics<T>: UnsafeUnpin,
impl<T> UnwindSafe for TransformerOptimizerState<T>where
ArrayBase<OwnedRepr<T>, Dim<[usize; 1]>>: UnwindSafe,
ParameterHistory<T>: UnwindSafe,
OptimizationState<T>: UnwindSafe,
LearningState<T>: UnwindSafe,
MemoryState<T>: UnwindSafe,
CheckpointManager<T>: UnwindSafe,
StateStatistics<T>: 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> 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 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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.