Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
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
Example #5
0
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()
Example #6
0
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()