def NormL1_project(x,weights,tau): if all(np.isreal(x)): return oneProjector(x,weights,tau) else: xa = abs(x) idx = xa < np.spacing(1) xc = oneProjector(xa,weights,tau) xc = xc / xa xc[idx] = 0 return x * xc
def NormL1_project(x, weights, tau): if all(np.isreal(x)): return oneProjector(x, weights, tau) else: xa = abs(x) idx = xa < np.spacing(1) xc = oneProjector(xa, weights, tau) xc = xc / xa xc[idx] = 0 return x * xc
def NormGroupL2_project(groups,x,weights,tau): if all(np.isreal(x)): xa = np.sqrt(np.sum(groups * x**2.,axis=1)) else: xa = np.sqrt(np.sum(groups * abs(x)**2.,axis=1)) idx = xa < spacing(1) xc = oneProjector(xa,weights,tau) xc = xc / xa xc[idx] = 0 return dot(np.conj(groups.T),xc)*x
def NormGroupL2_project(groups, x, weights, tau): if all(np.isreal(x)): xa = np.sqrt(np.sum(groups * x**2., axis=1)) else: xa = np.sqrt(np.sum(groups * abs(x)**2., axis=1)) idx = xa < spacing(1) xc = oneProjector(xa, weights, tau) xc = xc / xa xc[idx] = 0 return dot(np.conj(groups.T), xc) * x
def NormL12_project(g,x,weights,tau): m = round(np.size(x) / g) n = g x = reshape(x,m,n) if all(np.isreal(x)): xa = np.sqrt(np.sum(x**2,axis=1)) else: xa = np.sqrt(np.sum(abs(x)**2,axis=1)) idx = xa < spacing(1) xc = oneProjector(xa,weights,tau) xc = xc / xa xc[idx] = 0 x = np.sparse.spdiags(xc,0,m,m)*x return x.flatten()
def NormL12_project(g, x, weights, tau): m = round(np.size(x) / g) n = g x = reshape(x, m, n) if all(np.isreal(x)): xa = np.sqrt(np.sum(x**2, axis=1)) else: xa = np.sqrt(np.sum(abs(x)**2, axis=1)) idx = xa < spacing(1) xc = oneProjector(xa, weights, tau) xc = xc / xa xc[idx] = 0 x = np.sparse.spdiags(xc, 0, m, m) * x return x.flatten()