def _generate(l, k, g, beta, M, e, A, mu, intercept):

    p = beta.shape[0]

    if intercept:
        gradL1 = grad_l1(beta[1:, :])
        gradL2 = grad_l2_squared(beta[1:, :])
        gradTVmu = grad_tvmu(beta[1:, :], A, mu)
    else:
        gradL1 = grad_l1(beta)
        gradL2 = grad_l2_squared(beta)
        gradTVmu = grad_tvmu(beta, A, mu)

    alpha = -(l * gradL1 + k * gradL2 + g * gradTVmu)
    Mte = np.dot(M.T, e)
    if intercept:
        alpha = np.divide(alpha, Mte[1:, :])
    else:
        alpha = np.divide(alpha, Mte)

    X = np.ones(M.shape)
    if intercept:
        for i in xrange(p - 1):
            X[:, i + 1] = M[:, i + 1] * alpha[i, 0]
    else:
        for i in xrange(p):
            X[:, i] = M[:, i] * alpha[i, 0]

    y = np.dot(X, beta) - e

    return X, y
Ejemplo n.º 2
0
def _generate(l, k, g, beta, M, e, A, mu, intercept):

    p = beta.shape[0]

    if intercept:
        gradL1 = grad_l1(beta[1:, :])
        gradL2 = grad_l2_squared(beta[1:, :])
        gradTVmu = grad_tvmu(beta[1:, :], A, mu)
    else:
        gradL1 = grad_l1(beta)
        gradL2 = grad_l2_squared(beta)
        gradTVmu = grad_tvmu(beta, A, mu)

    alpha = -(l * gradL1 + k * gradL2 + g * gradTVmu)
    Mte = np.dot(M.T, e)
    if intercept:
        alpha = np.divide(alpha, Mte[1:, :])
    else:
        alpha = np.divide(alpha, Mte)

    X = np.ones(M.shape)
    if intercept:
        for i in xrange(p - 1):
            X[:, i + 1] = M[:, i + 1] * alpha[i, 0]
    else:
        for i in xrange(p):
            X[:, i] = M[:, i] * alpha[i, 0]

    y = np.dot(X, beta) - e

    return X, y
Ejemplo n.º 3
0
def _generate(l, k, g, beta, M, e, mu, shape):

    p = np.prod(shape)

    gradL1mu = grad_l1mu(beta, mu)
    gradL2 = grad_l2_squared(beta)
    gradTVmu = grad_tvmu(beta, shape, mu)

    alpha = -(l * gradL1mu + k * gradL2 + g * gradTVmu)
    alpha = np.divide(alpha, np.dot(M.T, e))

    X = np.zeros(M.shape)
    for i in xrange(p):
        X[:, i] = M[:, i] * alpha[i, 0]

    y = np.dot(X, beta) - e

    return X, y
Ejemplo n.º 4
0
def _generate(l, k, g, beta, M, e, mu, shape):

    p = np.prod(shape)

    gradL1mu = grad_l1mu(beta, mu)
    gradL2 = grad_l2_squared(beta)
    gradTVmu = grad_tvmu(beta, shape, mu)

    alpha = -(l * gradL1mu + k * gradL2 + g * gradTVmu)
    alpha = np.divide(alpha, np.dot(M.T, e))

    X = np.zeros(M.shape)
    for i in xrange(p):
        X[:, i] = M[:, i] * alpha[i, 0]

    y = np.dot(X, beta) - e

    return X, y