Example #1
0
 def __init__(
     self,
     params: Union[str, List[str]],
     trainable: bool,
     params_strict: bool = True,
     start_epoch: float = -1.0,
     end_epoch: float = -1.0,
 ):
     super(TrainableParamsModifier, self).__init__(
         start_epoch=-1,
         end_epoch=-1,
         end_comparator=-1,
     )
     self._params = self._validate_params(params)
     self._layer_names = [get_layer_name_from_param(p) for p in self._params]
     self._trainable = convert_to_bool(trainable)
     self._params_strict = convert_to_bool(params_strict)
     self._vars_to_trainable_orig = {}
     self.validate()
Example #2
0
    def __init__(
        self,
        params: Union[str, List[str]],
        init_sparsity: float,
        final_sparsity: float,
        start_epoch: float,
        end_epoch: float,
        update_frequency: float,
        inter_func: str = "cubic",
        log_types: Union[str, List[str]] = ALL_TOKEN,
        mask_type: Union[str, List[int]] = "unstructured",
        leave_enabled: bool = True,
    ):
        super(GMPruningModifier, self).__init__(
            log_types=log_types,
            start_epoch=start_epoch,
            min_start=-1.0,
            end_epoch=end_epoch,
            min_end=0.0,
            end_comparator=1,
            update_frequency=update_frequency,
            min_frequency=-1.0,
        )
        self._params = validate_str_iterable(params, "{} for params".format(
            self.__class__.__name__))  # type: List[str]
        self._layer_names = [
            get_layer_name_from_param(p) for p in self._params
        ]
        self._init_sparsity = init_sparsity
        self._final_sparsity = final_sparsity
        self._leave_enabled = convert_to_bool(leave_enabled)
        self._inter_func = inter_func
        self._mask_type = mask_type
        self._leave_enabled = convert_to_bool(leave_enabled)
        self._prune_op_vars = None
        self._update_ready = None
        self._sparsity = None
        self._mask_initializer = None

        self._masked_layers = []

        self.validate()
    def __init__(
        self,
        params: Union[str, List[str]],
        start_epoch: float = -1,
        end_epoch: float = -1,
        log_types: Union[str, List[str]] = ALL_TOKEN,
    ):
        super(ConstantPruningModifier, self).__init__(
            log_types=log_types,
            start_epoch=start_epoch,
            end_epoch=end_epoch,
            end_comparator=None,
        )
        self._params = validate_str_iterable(
            params, "{} for params".format(self.__class__.__name__)
        )  # type: List[str]
        self._layer_names = [get_layer_name_from_param(p) for p in self._params]
        self._masked_layers = []

        self._sparsity_scheduler = None
        self._mask_creator = load_mask_creator("unstructured")
Example #4
0
    def __init__(
        self,
        params: Union[str, List[str]],
        init_sparsity: float,
        final_sparsity: float,
        start_epoch: float,
        end_epoch: float,
        update_frequency: float,
        inter_func: str = "cubic",
        log_types: Union[str, List[str]] = ALL_TOKEN,
        mask_type: Union[str, List[int]] = "unstructured",
        leave_enabled: bool = True,
    ):
        super(GMPruningModifier, self).__init__(
            params=params,
            init_sparsity=init_sparsity,
            final_sparsity=final_sparsity,
            start_epoch=start_epoch,
            end_epoch=end_epoch,
            update_frequency=update_frequency,
            inter_func=inter_func,
            log_types=log_types,
            mask_type=mask_type,
            leave_enabled=leave_enabled,
            min_start=-1.0,
            min_end=0.0,
            end_comparator=1,
            min_frequency=-1.0,
        )
        self._layer_names = [get_layer_name_from_param(p) for p in self._params]
        self._prune_op_vars = None
        self._update_ready = None
        self._sparsity = None
        self._mask_initializer = None

        self._masked_layers = []