pub trait Pruner {
// Required methods
fn prune(
&self,
weights: &Array2<f64>,
) -> TrainResult<(Array2<f64>, PruningMask)>;
fn generate_mask(&self, weights: &Array2<f64>) -> TrainResult<PruningMask>;
fn apply_mask(
&self,
weights: &Array2<f64>,
mask: &PruningMask,
) -> TrainResult<Array2<f64>>;
fn config(&self) -> &PruningConfig;
fn update_ratio(&mut self, iteration: usize);
}Expand description
Trait for pruning strategies.
Required Methods§
Sourcefn 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.
Sourcefn generate_mask(&self, weights: &Array2<f64>) -> TrainResult<PruningMask>
fn generate_mask(&self, weights: &Array2<f64>) -> TrainResult<PruningMask>
Generate pruning mask without modifying weights.
Sourcefn 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.
Sourcefn config(&self) -> &PruningConfig
fn config(&self) -> &PruningConfig
Get pruning configuration.
Sourcefn update_ratio(&mut self, iteration: usize)
fn update_ratio(&mut self, iteration: usize)
Update pruning ratio for iterative pruning.