9d468d2c742491af2d2f506c648ddc95ffea6a64,src/sdk/pynni/nni/compression/torch/builtin_pruners.py,SensitivityPruner,calc_mask,#SensitivityPruner#Any#Any#Any#,107
Before Change
mask = self.mask_list.get(op_name, torch.ones(weight.shape).type_as(weight))
// if we want to generate new mask, we should update weight first
weight = weight * mask
target_sparsity = config["sparsity"] * torch.std(weight).item()
k = int(weight.numel() * target_sparsity)
if k == 0:
return mask
After Change
self.if_init_list = {}
def calc_mask(self, weight, config, op_name, **kwargs):
if self.if_init_list.get(op_name, True):
w_abs = weight.abs()
k = int(weight.numel() * config["sparsity"])
if k == 0:
return torch.ones(weight.shape).type_as(weight)
threshold = torch.topk(w_abs.view(-1), k, largest=False).values.max()
mask = torch.gt(w_abs, threshold).type_as(weight)
self.mask_list.update({op_name: mask})
self.if_init_list.update({op_name: False})
else:
mask = self.mask_list[op_name]
return mask
class AGP_Pruner(Pruner):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
Instances Project Name: microsoft/nni
Commit Name: 9d468d2c742491af2d2f506c648ddc95ffea6a64
Time: 2019-10-20
Author: lanny@mail.hfut.edu.cn
File Name: src/sdk/pynni/nni/compression/torch/builtin_pruners.py
Class Name: SensitivityPruner
Method Name: calc_mask
Project Name: keras-team/keras
Commit Name: ecbf73f72b59f8f5c8746de63270aa1fb3ad7524
Time: 2018-10-01
Author: gabrieldemarmiesse@gmail.com
File Name: keras/callbacks.py
Class Name: TensorBoard
Method Name: on_epoch_end
Project Name: allenai/allennlp
Commit Name: 87a61ad92a9e0129e5c81c242f0ea96d77e6b0af
Time: 2020-08-19
Author: akshita23bhagia@gmail.com
File Name: allennlp/training/metrics/pearson_correlation.py
Class Name: PearsonCorrelation
Method Name: get_metric