原有的损失函数:
alpha = 0.001
iters = 5000
def batch_gradient_descent(X,Y,theta,alpha,iters):
cost_history = [0] * iters # 初始化历史损失列表
for i in range(iters):
prediction = np.dot(X,theta.T)
theta = theta - (alpha/len(Y)) * np.dot(prediction - Y,X)
cost_history[i] = cost_function(X,Y,theta)
print(theta)
return theta,cost_history
加入新的约束以后,现在用拉格朗日乘子法重构后的损失函数该如何表达?
请问你这些图片的出处在哪?
这不应该修改损失函数吗?
这个在优化器里不是有参数吗?
修改损失函数