def lagrange_prox(self, X, lipschitz=1, lagrange=None): lagrange = svd_atom.lagrange_prox(self, X, lipschitz, lagrange) self.X = X U, D, V = self.SVD D_soft_thresholded = D - projl1(D, lagrange/lipschitz) keepD = D_soft_thresholded > 0 self.SVD = U[:,keepD], D_soft_thresholded[keepD], V[keepD] c = self.conjugate c.SVD = self.SVD self._X = np.dot(U[:,keepD], D_soft_thresholded[keepD][:,np.newaxis] * V[keepD]) return self.X
def bound_prox(self, X, lipschitz=1, bound=None): bound = svd_atom.bound_prox(self, X, lipschitz, bound) self.X = X U, D, V = self.SVD D_projected = projl1(D, self.bound) keepD = D_projected > 0 # store the projected X -- or should we keep original? self.SVD = U[:,keepD], D_projected[keepD], V[keepD] c = self.conjugate c.SVD = self.SVD self._X = np.dot(U[:,keepD], D_projected[keepD][:,np.newaxis] * V[keepD]) return self.X