carpet/loss_gradient.py
def analysis_dual_obj(v, A, D, x, lbda, Psi_A=None):
    """ Cost for the dual formulation of the analysis problem. """
    v = np.atleast_2d(v)
    if np.all(np.abs(v) <= lbda):
        n_samples = v.shape[0]
        Psi_A = np.linalg.pinv(A).dot(D) if Psi_A is None else Psi_A
        v_PsiAt = v.dot(Psi_A.T)
        cost = 0.5 * np.sum(v_PsiAt * v_PsiAt)
        cost -= np.sum(np.diag(x.dot(v_PsiAt.T)))
        return cost / n_samples
    else:
        return np.inf
 Cost for the dual formulation of the analysis problem. 
Cost for the dual formulation of the analysis problem.
Cost for the dual formulation of the analysis problem .
def analysis_dual_obj(v, A, D, x, lbda, Psi_A=None):
    v = np.atleast_2d(v)
    if np.all(np.abs(v) <= lbda):
        n_samples = v.shape[0]
        Psi_A = np.linalg.pinv(A).dot(D) if Psi_A is None else Psi_A
        v_PsiAt = v.dot(Psi_A.T)
        cost = 0.5 * np.sum(v_PsiAt * v_PsiAt)
        cost -= np.sum(np.diag(x.dot(v_PsiAt.T)))
        return cost / n_samples
    else:
        return np.inf
def analysis_dual_obj ( v , A , D , x , lbda , Psi_A = None ) : v = np . atleast_2d ( v ) if np . all ( np . abs ( v ) <= lbda ) : n_samples = v . shape [ 0 ] Psi_A = np . linalg . pinv ( A ) . dot ( D ) if Psi_A is None else Psi_A v_PsiAt = v . dot ( Psi_A . T ) cost = 0.5 * np . sum ( v_PsiAt * v_PsiAt ) cost -= np . sum ( np . diag ( x . dot ( v_PsiAt . T ) ) ) return cost / n_samples else : return np . inf
Cost for the dual formulation of the analysis problem.
Cost for the dual formulation of the analysis problem .
""" Cost for the dual formulation of the analysis problem. """
v
A
D
x
lbda
Psi_A