- mode(str): Pruning mode, must be selected from 'ratio' and 'threshold'.
- threshold(float): The parameters whose absolute values are smaller than the THRESHOLD will be zeros. Default: 0.01
- ratio(float): The parameters whose absolute values are in the smaller part decided by the ratio will be zeros. Default: 0.3
- skip_params_func(function): The function used to select the parameters which should be skipped when performing pruning. Default: normalization-related params.
"""
def__init__(self,
model,
mode,
threshold=0.01,
ratio=0.3,
skip_params_func=None):
assertmodein('ratio','threshold'
),"mode must be selected from 'ratio' and 'threshold'"
- program(paddle.static.Program): The model to be pruned.
- batch_size(int): batch size.
- mode(str): the mode to prune the model, must be selected from 'ratio' and 'threshold'.
- ratio(float): the ratio to prune the model. Only set it when mode=='ratio'. Default: 0.5.
- threshold(float): the threshold to prune the model. Only set it when mode=='threshold'. Default: 1e-5.
- scope(paddle.static.Scope): The scope storing values of all variables. None means paddle.static.global_scope. Default: None.
- place(CPUPlace | CUDAPlace): The device place used to execute model. None means CPUPlace. Default: None.
- skip_params_func(function): The function used to select the parameters which should be skipped when performing pruning. Default: normalization-related params.
"""
def__init__(self,
program,
batch_size,
mode,
ratio=0.5,
threshold=1e-5,
scope=None,
place=None,
skip_params_func=None):
self.mode=mode
self.ratio=ratio
self.threshold=threshold
assertself.modein[
'ratio','threshold'
],"mode must be selected from 'ratio' and 'threshold'"