def enet_regression_multi_gram_(G, Dx, X, code, l1_ratio, alpha,
positive):
batch_size = code.shape[0]
if l1_ratio == 0:
n_components = G.shape[1]
for i in range(batch_size):
G.flat[::n_components + 1] += alpha
code[i] = linalg.solve(G[i], Dx[i])
G.flat[::n_components + 1] -= 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],
alpha * l1_ratio,
alpha * (
1 - l1_ratio),
G[i], Dx[i], X[i], 100, 1e-2,
random_state,
False, positive)
return code
评论列表
文章目录