generated from LufsX/Experiment-LogReg
This commit is contained in:
+1
-1
@@ -55,7 +55,7 @@ def train_logreg(X, y, other_params=None):
|
||||
z = np.dot(X, weights)
|
||||
predictions = sigmoid(z)
|
||||
# 计算梯度
|
||||
gradient = np.dot(X.T, (predictions - y)) / m
|
||||
gradient = np.dot(X.T, (predictions.astype(float) - y.astype(float))) / m
|
||||
# 更新权重
|
||||
weights -= learning_rate * gradient
|
||||
|
||||
|
||||
Reference in New Issue
Block a user