pub struct ParameterManager<A: Float, D: Dimension> { /* private fields */ }Expand description
Neural network parameter manager with lazy registration
Implementations§
Source§impl<A: Float + ScalarOperand + Debug + Send + Sync, D: Dimension + Send + Sync> ParameterManager<A, D>
impl<A: Float + ScalarOperand + Debug + Send + Sync, D: Dimension + Send + Sync> ParameterManager<A, D>
Sourcepub fn new(config: OptimizationConfig<A>) -> Self
pub fn new(config: OptimizationConfig<A>) -> Self
Create a new parameter manager
Sourcepub fn enable_lazy_mode(&mut self)
pub fn enable_lazy_mode(&mut self)
Enable lazy registration mode
Sourcepub fn disable_lazy_mode(&mut self) -> Result<()>
pub fn disable_lazy_mode(&mut self) -> Result<()>
Disable lazy registration mode and process pending registrations
Sourcepub fn register_layer(
&mut self,
layerid: LayerId,
architecture: LayerArchitecture,
)
pub fn register_layer( &mut self, layerid: LayerId, architecture: LayerArchitecture, )
Register a layer architecture
Sourcepub fn set_layer_rule(
&mut self,
layerid: LayerId,
rule: LayerOptimizationRule<A>,
)
pub fn set_layer_rule( &mut self, layerid: LayerId, rule: LayerOptimizationRule<A>, )
Set layer-specific optimization rule
Sourcepub fn register_parameter(
&mut self,
paramid: ParamId,
metadata: ParameterMetadata,
) -> Result<()>
pub fn register_parameter( &mut self, paramid: ParamId, metadata: ParameterMetadata, ) -> Result<()>
Register a parameter
Sourcepub fn get_effective_learning_rate(&self, paramid: &ParamId) -> A
pub fn get_effective_learning_rate(&self, paramid: &ParamId) -> A
Get effective learning rate for a parameter
Sourcepub fn get_effective_weight_decay(&self, paramid: &ParamId) -> A
pub fn get_effective_weight_decay(&self, paramid: &ParamId) -> A
Get effective weight decay for a parameter
Sourcepub fn is_parameter_frozen(&self, paramid: &ParamId) -> bool
pub fn is_parameter_frozen(&self, paramid: &ParamId) -> bool
Check if parameter is frozen
Sourcepub fn get_sharing_group(&self, groupname: &str) -> Option<&[ParamId]>
pub fn get_sharing_group(&self, groupname: &str) -> Option<&[ParamId]>
Get parameters in a sharing group
Sourcepub fn get_all_parameters(&self) -> &HashMap<ParamId, ParameterMetadata>
pub fn get_all_parameters(&self) -> &HashMap<ParamId, ParameterMetadata>
Get all registered parameters
Sourcepub fn get_layer_architecture(
&self,
layerid: &LayerId,
) -> Option<&LayerArchitecture>
pub fn get_layer_architecture( &self, layerid: &LayerId, ) -> Option<&LayerArchitecture>
Get layer architecture
Sourcepub fn get_parameter_metadata(
&self,
paramid: &ParamId,
) -> Option<&ParameterMetadata>
pub fn get_parameter_metadata( &self, paramid: &ParamId, ) -> Option<&ParameterMetadata>
Get parameter metadata
Sourcepub fn update_config(&mut self, config: OptimizationConfig<A>)
pub fn update_config(&mut self, config: OptimizationConfig<A>)
Update global configuration
Sourcepub fn get_optimizer_state(
&self,
paramid: &ParamId,
) -> Option<&HashMap<String, Array<A, D>>>
pub fn get_optimizer_state( &self, paramid: &ParamId, ) -> Option<&HashMap<String, Array<A, D>>>
Get optimizer state for parameter
Sourcepub fn get_optimizer_state_mut(
&mut self,
paramid: &ParamId,
) -> Option<&mut HashMap<String, Array<A, D>>>
pub fn get_optimizer_state_mut( &mut self, paramid: &ParamId, ) -> Option<&mut HashMap<String, Array<A, D>>>
Get mutable optimizer state for parameter
Sourcepub fn init_optimizer_state(
&mut self,
paramid: &ParamId,
state_name: &str,
state: Array<A, D>,
) -> Result<()>
pub fn init_optimizer_state( &mut self, paramid: &ParamId, state_name: &str, state: Array<A, D>, ) -> Result<()>
Initialize optimizer state for parameter
Sourcepub fn reset_optimizer_states(&mut self)
pub fn reset_optimizer_states(&mut self)
Reset all optimizer states
Sourcepub fn get_parameters_by_layer(&self, layerid: &LayerId) -> Vec<&ParamId> ⓘ
pub fn get_parameters_by_layer(&self, layerid: &LayerId) -> Vec<&ParamId> ⓘ
Get parameters by layer
Sourcepub fn get_parameters_by_type(&self, paramtype: ParameterType) -> Vec<&ParamId> ⓘ
pub fn get_parameters_by_type(&self, paramtype: ParameterType) -> Vec<&ParamId> ⓘ
Get parameters by type
Sourcepub fn get_trainable_parameters(&self) -> Vec<&ParamId> ⓘ
pub fn get_trainable_parameters(&self) -> Vec<&ParamId> ⓘ
Get trainable parameters
Trait Implementations§
Auto Trait Implementations§
impl<A, D> Freeze for ParameterManager<A, D>where
A: Freeze,
impl<A, D> RefUnwindSafe for ParameterManager<A, D>where
A: RefUnwindSafe,
D: RefUnwindSafe,
impl<A, D> Send for ParameterManager<A, D>where
A: Send,
impl<A, D> Sync for ParameterManager<A, D>where
A: Sync,
impl<A, D> Unpin for ParameterManager<A, D>
impl<A, D> UnwindSafe for ParameterManager<A, D>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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.