Пример #1
0
def norm_nuclear(X):
    r"""Compute the nuclear norm

    .. math::
      \| X \|_* = \sum_i \sigma_i

    where :math:`\sigma_i` are the singular values of matrix :math:`X`.


    Parameters
    ----------
    X : array_like
      Input array :math:`X`

    Returns
    -------
    nncl : float
      Nuclear norm of `X`
    """

    return np.sum(np.linalg.svd(sl.promote16(X), compute_uv=False))
Пример #2
0
def norm_nuclear(X):
    r"""Compute the nuclear norm

    .. math::
      \| X \|_* = \sum_i \sigma_i

    where :math:`\sigma_i` are the singular values of matrix :math:`X`.


    Parameters
    ----------
    X : array_like
      Input array :math:`X`

    Returns
    -------
    nncl : float
      Nuclear norm of `X`
    """

    return np.sum(np.linalg.svd(sl.promote16(X), compute_uv=False))
Пример #3
0
def prox_nuclear(v, alpha):
    r"""Proximal operator of the nuclear norm :cite:`cai-2010-singular`.


    Parameters
    ----------
    v : array_like
      Input array :math:`V`
    alpha : float
      Parameter :math:`\alpha`

    Returns
    -------
    x : ndarray
      Output array
    s : ndarray
      Singular values of `x`
    """

    U, s, V = sl.promote16(v, fn=np.linalg.svd, full_matrices=False)
    ss = np.maximum(0, s - alpha)
    return np.dot(U, np.dot(np.diag(ss), V)), ss
Пример #4
0
def prox_nuclear(V, alpha):
    r"""Proximal operator of the nuclear norm :cite:`cai-2010-singular`
    with parameter :math:`\alpha`.


    Parameters
    ----------
    v : array_like
      Input array :math:`V`
    alpha : float
      Parameter :math:`\alpha`

    Returns
    -------
    X : ndarray
      Output array
    s : ndarray
      Singular values of `X`
    """

    Usvd, s, Vsvd = sl.promote16(V, fn=np.linalg.svd, full_matrices=False)
    ss = np.maximum(0, s - alpha)
    return np.dot(Usvd, np.dot(np.diag(ss), Vsvd)), ss
Пример #5
0
def nucnorm(x):
    """Nuclear norm"""

    return np.sum(np.linalg.svd(sl.promote16(x), compute_uv=False))
Пример #6
0
def shrinksv(v, alpha):
    """Shrinkage of singular values"""

    U, s, V = sl.promote16(v, fn=np.linalg.svd, full_matrices=False)
    ss = np.maximum(0, s - alpha)
    return np.dot(U, np.dot(np.diag(ss), V)), ss