예제 #1
0

def print_results(alg, x, time2run):
    print("===results summary for " + alg + "===")
    print("running time " + str(time2run))
    print(alg + " training error: " + str(gp.training_error_rate(A, x, y)))
    print(alg + " nnz: " + str(sum(abs(x) > 1e-5)))
    group_norms = gp.nnz_groups(Partitions, x)
    print(alg + " nnz groups: " + str(sum(group_norms > 1e-5)))
    print("=== end results summary===")


print('##################')
print('##################')
print("running ada3op")
init = algo.InitPoint([], [], np.zeros(d + 1), [])
out3op = algo.adap3op(group_prox,
                      theGrad_smart,
                      lrFunc,
                      theFunc,
                      prox_L1,
                      lrFunc_smart,
                      init,
                      stepIncrease=step_increase,
                      iter=iter,
                      lip_const=lam1,
                      gamma=initial_stepsize)
print_results("ada3op", out3op.x, out3op.times[-1])

print("running 1fbt...")
init = algo.InitPoint(np.zeros(d + 1), np.zeros(d + 1), np.zeros(d + 1),
예제 #2
0

    maxIter = 10000
    algos2run = ['ps2fembed_g']
    numTrialPoints = 13
    start = -6
    end = 6
    trials = np.logspace(start,end,numTrialPoints)
    results = {}
    i = 0

    for tuned in trials:
        print(f"tuned = {tuned}")

        if False:
            init = algo.InitPoint([],np.zeros(d),np.zeros(d),np.zeros(p))
            out1f = algo.PS1f_bt_comp(init,maxIter,G,theProx1,theProx2,
                                  theGrad,Gt,theFunc,gamma = tuned,
                                  equalRhos=False,getFuncVals=False,verbose=False)
            results[(i,'1f')] =  out1f.finalFuncVal

        if False:
            init = algo.InitPoint([],[],np.zeros(d),np.zeros(p))
            out2f = algo.PS2f_bt_comp(init,int(0.5*maxIter),G,theProx1,theProx2,theGrad,Gt,
                              theFunc,gamma=tuned,equalRhos=False,getFuncVals=False,verbose=False)
            results[(i,'2f')] =  out2f.finalFuncVal

        if False:
            init = algo.InitPoint(np.zeros(d),np.zeros(p),[],[])
            outcp = algo.cpBT(theProx2, theGradSmart, proxg, theFunc, hfunc, init, iter=maxIter,
                          beta=tuned,stepInc=1.1,K=Gt,Kstar=G,verbose=False,getFuncVals=False)
예제 #3
0
    print("running cvx...")
    tstart_cvx = time.time()

    [cvxopt, xopt] = algo.runCVX_portfolio(d, Q, m, r)
    tend_cvx = time.time()
    print("CVX runtime: " + str(tend_cvx - tstart_cvx))

print("=========================")
print("Running projective splitting one-forward-step backtrack... (ps1fbt)")

# initPoint returns an initial point to start the algorithm.
# initPoint is called before every algorithm to ensure we get new memory for
# each new variable

initPoint = algo.InitPoint(
    np.ones(d) / d,
    np.ones(d) / d,
    np.ones(d) / d, np.zeros(d))
out1f = algo.PS1f_bt(theFunc,
                     theProx1,
                     theProx2,
                     theGrad,
                     initPoint,
                     gamma=gamma1f,
                     hyper_resid=hyper_resid,
                     verbose=verbose,
                     iter=iter,
                     adaptive_gamma=False)

print_results("1fbt", out1f.times[-1], out1f.x1, out1f.grad_evals)

print("=========================")