(module, density)
return T.threshold(params, density)
Computes a magnitude-based threshold for given module.

    :param module: PyTorch module
    :type module: `torch.nn.Module`
    :param density: Desired ratio of nonzeros to total elements
    :type density: `float`
    :return: Magnitude threshold
    :rtype: `float`
Computes a magnitude-based threshold for given module.
Computes a magnitude - based threshold for given module .
def magnitude_threshold(module, density):
    """
    Computes a magnitude-based threshold for given module.

    :param module: PyTorch module
    :type module: `torch.nn.Module`
    :param density: Desired ratio of nonzeros to total elements
    :type density: `float`
    :return: Magnitude threshold
    :rtype: `float`
    """
    params = torch.nn.utils.parameters_to_vector(module.parameters())
    return T.threshold(params, density)
def magnitude_threshold ( module , density ) : params = torch . nn . utils . parameters_to_vector ( module . parameters ( ) ) return T . threshold ( params , density )