# tensorplay.ao.pruning.l1_unstructured Source: https://www.tensorplay.cn/docs/generated/tensorplay.ao.pruning.l1_unstructured.html ```python tensorplay.ao.pruning.l1_unstructured(module: Module, name: str, amount: int | float, importance_scores: Tensor | None = None) → Module ``` Prune module[name] by removing the units with the smallest magnitudes. Removes amount (currently unpruned) units ranked by absolute value. Modifies the module in place (and also returns it) by: - adding a named buffer called name + '_mask' holding the binary mask applied to the parameter name; - replacing the parameter name by its masked version, while the original (unmasked) values are stored in a new parameter named name + '_orig'. Parameters: - module – module containing the tensor to prune. - name – parameter name within module on which pruning acts. - amount – quantity of units to prune. A float in [0, 1] denotes the fraction of units to prune; an int denotes the absolute number of units to prune. - importance_scores – tensor of importance scores with the same shape as the parameter; each entry ranks the corresponding element of the parameter. When unspecified, the parameter itself is used. Returns: The modified (i.e. pruned) module. Examples ``` >>> # xdoctest: +SKIP >>> m = l1_unstructured(nn.Linear(2, 3), "weight", amount=0.2) >>> list(m.state_dict().keys()) ['bias', 'weight_orig', 'weight_mask'] ```