def enet_regression_single_gram_(G, Dx, X, code, code_l1_ratio, code_alpha,
code_pos):
batch_size = code.shape[0]
if code_l1_ratio == 0:
n_components = G.shape[0]
G = G.copy()
G.flat[::n_components + 1] += code_alpha
code[:] = linalg.solve(G, Dx.T).T
G.flat[::n_components + 1] -= code_alpha
else:
# Unused but unfortunate API
random_state = check_random_state(0)
for i in range(batch_size):
cd_fast.enet_coordinate_descent_gram(
code[i],
code_alpha * code_l1_ratio,
code_alpha * (
1 - code_l1_ratio),
G, Dx[i], X[i], 100, 1e-2,
random_state,
False, code_pos)
return code
评论列表
文章目录