# tensorplay.ao.pruning.random_structured Source: https://www.tensorplay.cn/docs/generated/tensorplay.ao.pruning.random_structured.html ```python tensorplay.ao.pruning.random_structured(module: Module, name: str, amount: int | float, dim: int) → Module ``` Prune module[name] by removing random channels along dim. Removes amount (currently unpruned) channels chosen uniformly at random. 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 channels to prune. A float in [0, 1] denotes the fraction of channels to prune; an int denotes the absolute number of channels to prune. - dim – axis along which channels are defined. Returns: The modified (i.e. pruned) module. Examples ``` >>> # xdoctest: +SKIP >>> m = random_structured(nn.Linear(5, 3), "weight", amount=3, dim=1) >>> columns_pruned = int(sum(tensorplay.sum(m.weight, dim=0) == 0)) >>> print(columns_pruned) 3 ```