(tensor)
return 1. - density(tensor)
Computes the ratio of zeros to total elements in a tensor.

    :param tensor: PyTorch tensor
    :type tensor: torch.Tensor
    :return: Ratio of zeros to total elements
    :rtype: `float`
Computes the ratio of zeros to total elements in a tensor.
Computes the ratio of zeros to total elements in a tensor .
def sparsity(tensor):
    """
    Computes the ratio of zeros to total elements in a tensor.

    :param tensor: PyTorch tensor
    :type tensor: torch.Tensor
    :return: Ratio of zeros to total elements
    :rtype: `float`
    """
    return 1. - density(tensor)
def sparsity ( tensor ) : return 1. - density ( tensor )