def norm_filters(weights, p=1):
    """Compute the p-norm of convolution filters.

    Args:
        weights - a 4D convolution weights tensor.
                  Has shape = (#filters, #channels, k_w, k_h)
        p - the exponent value in the norm formulation
    """
    assert weights.dim() == 4
    return weights.view(weights.size(0), -1).norm(p=p, dim=1)