pub struct ParamGroup {
pub params: Vec<Arc<RwLock<Tensor>>>,
pub lr: f32,
pub options: HashMap<String, f32>,
}Expand description
Parameter group
Fields§
§params: Vec<Arc<RwLock<Tensor>>>§lr: f32§options: HashMap<String, f32>Implementations§
Source§impl ParamGroup
impl ParamGroup
pub fn new(params: Vec<Arc<RwLock<Tensor>>>, lr: f32) -> Self
pub fn with_options(self, options: HashMap<String, f32>) -> Self
Sourcepub fn get_option(&self, key: &str, default: f32) -> f32
pub fn get_option(&self, key: &str, default: f32) -> f32
Get a specific option value, falling back to a default
Sourcepub fn set_option(&mut self, key: String, value: f32)
pub fn set_option(&mut self, key: String, value: f32)
Set a specific option value
Sourcepub fn param_count(&self) -> usize
pub fn param_count(&self) -> usize
Get the number of parameters in this group
Sourcepub fn params_with_grads(&self) -> Vec<&Arc<RwLock<Tensor>>>
pub fn params_with_grads(&self) -> Vec<&Arc<RwLock<Tensor>>>
Get all parameters that have gradients
Sourcepub fn get_shape_counts(&self) -> HashMap<Vec<usize>, usize>
pub fn get_shape_counts(&self) -> HashMap<Vec<usize>, usize>
Get parameter count for each unique shape in the group
Sourcepub fn total_param_count(&self) -> usize
pub fn total_param_count(&self) -> usize
Get total number of parameters (not tensors, but individual parameters)
Sourcepub fn has_any_grads(&self) -> bool
pub fn has_any_grads(&self) -> bool
Check if any parameter in the group has gradients
Sourcepub fn clip_grads(&self, max_norm: f32) -> Result<f32>
pub fn clip_grads(&self, max_norm: f32) -> Result<f32>
Apply gradient clipping to all parameters in the group
Trait Implementations§
Source§impl Clone for ParamGroup
impl Clone for ParamGroup
Source§fn clone(&self) -> ParamGroup
fn clone(&self) -> ParamGroup
Returns a duplicate of the value. Read more
1.0.0 · 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 Freeze for ParamGroup
impl !RefUnwindSafe for ParamGroup
impl Send for ParamGroup
impl Sync for ParamGroup
impl Unpin for ParamGroup
impl UnsafeUnpin for ParamGroup
impl !UnwindSafe for ParamGroup
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> 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