def g_of_w(x, parameters): b = parameters[0] p = parameters[1] q = parameters[2] w = x eta = parameters[4] acc = g_sum(b, p, q, w, eta) return acc + beta * euclidean_norm(w)**2
def g_of_b(x, parameters): b = x p = parameters[1] q = parameters[2] w = parameters[3] eta = parameters[4] acc = g_sum(b, p, q, w, eta) return acc + beta * euclidean_norm(b)**2
def g_of_eta(x, parameters): b = parameters[0] p = parameters[1] q = parameters[2] w = parameters[3] eta = x acc = g_sum(b, p, q, w, eta) acc2 = 0 for i in range(eta.shape[0]): acc2 += euclidean_norm(eta[i])**2 return acc + beta * acc2
def g_of_q(x, parameters): b = parameters[0] p = parameters[1] q = x w = parameters[3] eta = parameters[4] acc = g_sum(b, p, q, w, eta) acc2 = 0 for i in range(q.shape[0]): acc2 += euclidean_norm(q[i])**2 return acc + beta * acc2
def g_of_p(x, parameters): b = parameters[0] p = x q = parameters[2] w = parameters[3] eta = parameters[4] acc = g_sum(b, p, q, w, eta) acc2 = 0 for t in range(len(p)): for i in range(p[t].shape[0]): acc2 += euclidean_norm(p[t][i])**2 acc3 = 0 for i in U: for t in range(tui[i] + 1, len(O_train)): for k in range(K): acc3 += c_of(p[t][i,k],p[t-1][i,k]) return acc + beta * acc2 + lmbda * acc3
def g_of_p(x, parameters): b = parameters[0] p = x q = parameters[2] w = parameters[3] eta = parameters[4] acc = g_sum(b, p, q, w, eta) acc2 = 0 for t in range(len(p)): for i in range(p[t].shape[0]): acc2 += euclidean_norm(p[t][i])**2 acc3 = 0 for i in U: for t in range(tui[i] + 1, len(O_train)): for k in range(K): acc3 += c_of(p[t][i, k], p[t - 1][i, k]) return acc + beta * acc2 + lmbda * acc3