pub struct GradientPruner { /* private fields */ }Expand description
Gradient-based pruning (prune weights with smallest gradients).
Implementations§
Source§impl GradientPruner
impl GradientPruner
Sourcepub fn new(config: PruningConfig) -> Self
pub fn new(config: PruningConfig) -> Self
Create a new gradient-based pruner.
Sourcepub fn update_gradients(&mut self, layer_name: &str, gradients: Array2<f64>)
pub fn update_gradients(&mut self, layer_name: &str, gradients: Array2<f64>)
Update gradient history for a layer.
Sourcepub fn prune_with_history(
&self,
weights: &Array2<f64>,
layer_name: &str,
) -> TrainResult<(Array2<f64>, PruningMask)>
pub fn prune_with_history( &self, weights: &Array2<f64>, layer_name: &str, ) -> TrainResult<(Array2<f64>, PruningMask)>
Prune based on gradient history.
Trait Implementations§
Source§impl Pruner for GradientPruner
impl Pruner for GradientPruner
Source§fn prune(
&self,
weights: &Array2<f64>,
) -> TrainResult<(Array2<f64>, PruningMask)>
fn prune( &self, weights: &Array2<f64>, ) -> TrainResult<(Array2<f64>, PruningMask)>
Prune weights and return pruned weights and mask.
Source§fn generate_mask(&self, weights: &Array2<f64>) -> TrainResult<PruningMask>
fn generate_mask(&self, weights: &Array2<f64>) -> TrainResult<PruningMask>
Generate pruning mask without modifying weights.
Source§fn apply_mask(
&self,
weights: &Array2<f64>,
mask: &PruningMask,
) -> TrainResult<Array2<f64>>
fn apply_mask( &self, weights: &Array2<f64>, mask: &PruningMask, ) -> TrainResult<Array2<f64>>
Apply existing mask to weights.
Source§fn config(&self) -> &PruningConfig
fn config(&self) -> &PruningConfig
Get pruning configuration.
Source§fn update_ratio(&mut self, iteration: usize)
fn update_ratio(&mut self, iteration: usize)
Update pruning ratio for iterative pruning.
Auto Trait Implementations§
impl Freeze for GradientPruner
impl RefUnwindSafe for GradientPruner
impl Send for GradientPruner
impl Sync for GradientPruner
impl Unpin for GradientPruner
impl UnwindSafe for GradientPruner
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