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)
评论列表
文章目录