regression.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:l1l2py 作者: slipguru 项目源码 文件源码
def get_lipschitz(data):
    """Get the Lipschitz constant for a specific loss function.

    Only square loss implemented.

    Parameters
    ----------
    data : (n, d) float ndarray
        data matrix
    loss : string
        the selected loss function in {'square', 'logit'}
    Returns
    ----------
    L : float
        the Lipschitz constant
    """
    n, p = data.shape

    if p > n:
        tmp = np.dot(data, data.T)
    else:
        tmp = np.dot(data.T, data)
    return la.norm(tmp, 2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号