基于这个方程,我必须计算导数w.r.tb,这是我下面所做的。
优化方程

def derivative_db(user_id,item_id,rating,U,V,mu,alpha):
'''In this function, we will compute dL/db_i'''
return (2*alpha*np.sum(user_id))-(2*np.sum((rating-mu-user_id-item_id-np.dot(U,V))))但是对于查询
U1, Sigma, V1 = randomized_svd(adjacency_matrix, n_components=2,n_iter=5, random_state=24)
U1.shape = (943,2)
V1.shape = (2,1681)
alpha=0.01
mu = 3.529
value=derivative_db(312,98,4,U1,V1,mu,alpha)我应该得到答案= -0.931
但我得到了一个巨大的数字。
我应该在我的职能上做什么修正?
发布于 2021-12-27 15:24:21
def derivative_db(user_id,item_id,rating,U,V,mu,alpha):
'''In this function, we will compute dL/db_i'''
U1 = U[user_id]
V1 = V.T[item_id]
a = alpha * 2 *(b_i[user_id]) - 2 * np.sum((rating - mu - b_i[user_id] - c_j[item_id] - np.dot(U1 , V1)))
return a发布于 2021-05-02 01:46:00
你实际上误解了它。尝试使用下面的代码,它将适用于您的作业。
def derivative_db(user_id,item_id,rating,U,V,mu,alpha):
'''In this function, we will compute dL/db_i'''
db=2*alpha*(b_i[user_id])-2*(rating-mu-b_i[user_id]-c_j[item_id]-np.dot(U[user_id],V[:,item_id].T))
return dbhttps://stackoverflow.com/questions/67277501
复制相似问题