# L1Unstructured Source: https://www.tensorplay.cn/docs/generated/tensorplay.ao.pruning.L1Unstructured.html ```python class tensorplay.ao.pruning.L1Unstructured(amount: int | float) ``` Zero out the units with the smallest magnitudes. Ranks all currently unpruned units by absolute value and removes the amount smallest ones. Parameters: 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. ```python classmethod apply(module: Module, name: str, amount: int | float, importance_scores: Tensor | None = None) → BasePruningMethod ``` Install magnitude-based unstructured pruning for module[name]. 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. ```python apply_mask(module: Module) → Tensor ``` Return the pruned version of the tensor held by module. Fetches the mask and the original values from the module and returns their elementwise product. Parameters: module – module holding the pruned tensor. Returns: The product of the mask and the original values. ```python prune(t: Tensor, default_mask: Tensor | None = None, importance_scores: Tensor | None = None) → Tensor ``` Return a pruned copy of the input tensor t. Applies the rule implemented by compute_mask() without any module-side reparameterization. Parameters: - t – tensor to prune (same shape as default_mask). - importance_scores – tensor of importance scores with the same shape as t; each entry ranks the corresponding element of t. When unspecified, t itself is used. - default_mask – mask from a previous pruning iteration, if any. Pruning must respect the entries it already zeroes. When unspecified, a mask of ones is used. Returns: The pruned version of t. ```python remove(module: Module) → None ``` Make the current pruning of module permanent. The pruned values remain pruned: the product of mask and original values is written back into the parameter name, and the auxiliary parameter name + '_orig' and buffer name + '_mask' are dropped. > **Note** > > Pruning itself is NOT undone or reversed!