def grad(w): return (logreg(w.reshape((w.shape[0], 1)), Z_mat, gamma, hess=True)[1])[:, 0]
def oracle_hess(w): return logreg(w, Z_mat, gamma, hess=True)
def fun(w): return logreg(w.reshape((w.shape[0], 1)), Z_mat, gamma, hess=True)[0]
def oracle(w): return logreg(w, Z_mat, gamma, hess=False)
def fun(w): f, g = logreg(w.reshape((w.shape[0], 1)), Z_mat, gamma, hess=False) return f, g[:, 0]