pub struct ParameterAverager<A: Float, D: Dimension> { /* private fields */ }
Expand description
Distributed parameter averager
Implementations§
Source§impl<A: Float + ScalarOperand + Debug, D: Dimension> ParameterAverager<A, D>
impl<A: Float + ScalarOperand + Debug, D: Dimension> ParameterAverager<A, D>
Sourcepub fn new(strategy: AveragingStrategy, num_nodes: usize) -> Self
pub fn new(strategy: AveragingStrategy, num_nodes: usize) -> Self
Create a new parameter averager
Sourcepub fn initialize(&mut self, params: &[Array<A, D>]) -> Result<()>
pub fn initialize(&mut self, params: &[Array<A, D>]) -> Result<()>
Initialize averager with parameter shapes
Sourcepub fn set_node_weight(&mut self, node_id: usize, weight: A) -> Result<()>
pub fn set_node_weight(&mut self, node_id: usize, weight: A) -> Result<()>
Set weight for a specific node
Sourcepub fn average_parameters(
&mut self,
node_parameters: &[(usize, Vec<Array<A, D>>)],
) -> Result<()>
pub fn average_parameters( &mut self, node_parameters: &[(usize, Vec<Array<A, D>>)], ) -> Result<()>
Average parameters from multiple nodes
Sourcepub fn get_averaged_parameters(&self) -> &[Array<A, D>] ⓘ
pub fn get_averaged_parameters(&self) -> &[Array<A, D>] ⓘ
Get current averaged parameters
Sourcepub fn get_averaged_parameters_cloned(&self) -> Vec<Array<A, D>> ⓘ
pub fn get_averaged_parameters_cloned(&self) -> Vec<Array<A, D>> ⓘ
Get cloned averaged parameters
Sourcepub fn step_count(&self) -> usize
pub fn step_count(&self) -> usize
Get step count
Sourcepub fn strategy(&self) -> AveragingStrategy
pub fn strategy(&self) -> AveragingStrategy
Get averaging strategy
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if initialized
Trait Implementations§
Auto Trait Implementations§
impl<A, D> Freeze for ParameterAverager<A, D>
impl<A, D> RefUnwindSafe for ParameterAverager<A, D>where
D: RefUnwindSafe,
A: RefUnwindSafe,
impl<A, D> Send for ParameterAverager<A, D>where
A: Send,
impl<A, D> Sync for ParameterAverager<A, D>where
A: Sync,
impl<A, D> Unpin for ParameterAverager<A, D>
impl<A, D> UnwindSafe for ParameterAverager<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 more