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) results[(i,'cp')] = outcp.finalFuncVal if False: init = algo.InitPoint([],[],np.zeros(d),np.zeros(p)) outtseng = algo.tseng_product(theFunc, proxfstar_4_tseng, proxg, theGrad, init,verbose=False,getFuncVals=False, iter=maxIter, gamma1=tuned,gamma2=tuned,G=G,Gt=Gt) results[(i,'tseng')] = outtseng.finalFuncVal if False: outfrb = algo.for_reflect_back(theFunc,proxfstar_4_tseng,proxg,theGrad,init,iter=maxIter, gamma0=tuned,gamma1=tuned,G=G,Gt=Gt,verbose=False,getFuncVals=False) results[(i,'frb')] = outfrb.finalFuncVal if loss == "log": loss2use = "logistic" else: loss2use = 2 gamma = 1.0 if True : psObj = ps.ProjSplitFit(gamma)
#print("1f") #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 = gamma1f,equalRhos=False,verbose=False) if runTseng: print("Tseng") init = algo.InitPoint([], [], np.zeros(d), np.zeros(p)) outtseng = algo.tseng_product(theFunc, proxfstar_4_tseng, proxg, theGrad, init, verbose=True, getFuncVals=True, iter=maxIter // 2, gamma1=tsengs[i], gamma2=tsengs[i], G=G, Gt=Gt, historyFreq=20) if runFRB: print("FRB") outfrb = algo.for_reflect_back(theFunc, proxfstar_4_tseng, proxg, theGrad, init, iter=maxIter,
beta=betacp, iter=iter, verbose=verbose) print_results("cp-bt", outcp.times[-1], outcp.y, outcp.func_evals) print("=========================") print("running Tseng-pd...") init = algo.InitPoint([], [], np.ones(d) / d, np.ones(d) / d) outTseng = algo.tseng_product(theFunc, proxfstar4Tseng, proxgstar4Tseng, theGrad, init, hyper_resid=hyper_resid, iter=iter, gamma1=gamma_tg, gamma2=gamma_tg, verbose=verbose) print_results("tseng-pd", outTseng.times[-1], outTseng.x, outTseng.grad_evals) print("total Runtime for all algorithms: " + str(time.time() - tBegin)) print("=========================") print("plotting...") plt.plot(out1f.rhos) plt.plot(out2f.rhos, ':') plt.xlabel('iterations') plt.title('discovered stepsizes via backtracking for portfolio')
theFunc, the_func_smart_for_cp, init, iter=iter, beta=betacp, stepInc=step_increase, tau=initial_stepsize / betacp) print_results("cp-bt", outcp.y, outcp.times[-1]) print("Running Tseng-pd") init = algo.InitPoint([], [], np.zeros(d + 1), np.zeros(d + 1)) outTseng = algo.tseng_product(theFunc, proxfstar4tseng, proxgstar4tseng, theGrad, init, stepIncrease=step_increase, alpha=initial_stepsize, gamma1=gammatg, gamma2=gammatg, iter=iter) print_results("tseng-pd", outTseng.x, outTseng.times[-1]) print("running FRB...") init = algo.InitPoint([], [], np.zeros(d + 1), np.zeros(d + 1)) outFRB = algo.for_reflect_back(theFunc, proxfstar4tseng, proxgstar4tseng, theGrad, init, iter=iter, gamma0=gammafrb,
print("2f TOTAL running time: "+str(out2f.times[-1])) print("================") print("running cp-bt...") init = algo.InitPoint(np.zeros(d),np.zeros(p),[],[]) outcp = algo.cpBT(theProx2, theGradSmart, proxg, theFunc, hfunc, init, iter=iterOverwrite, beta=betacp,stepInc=1.1,K=Gt,Kstar=G) print("cp-bt TOTAL running time: "+str(outcp.times[-1])) print("================") print("running tseng...") # Since Tseng computes two forward steps per iteration, only run it for half as # many iterations to get similar times to the other methods. init = algo.InitPoint([],[],np.zeros(d),np.zeros(p)) outtseng = algo.tseng_product(theFunc, proxfstar_4_tseng, proxg, theGrad, init, iter=iterOverwrite, gamma1=gammatg,gamma2=gammatg,G=G,Gt=Gt) print("TOTAL tseng time: "+str(outtseng.times[-1])) print("================") print("running frb...") outfrb = algo.for_reflect_back(theFunc,proxfstar_4_tseng,proxg,theGrad,init,iter=iterOverwrite, gamma0=gammafrb,gamma1=gammafrb,G=G,Gt=Gt) print("frb running time: "+str(outfrb.times[-1])) print("================") print("running ProjSplitFit") X = sp.load_npz('data/trip_advisor/S_train.npz') # training matrix H = sp.load_npz('data/trip_advisor/S_A.npz') # this matrix is called H y = np.load('data/trip_advisor/y_train.npy') # training labels f_ps2fg = []