更新 function.py
Gitea Actions Experiment Test / Experiment-Actions (push) Successful in 20s

This commit is contained in:
2024-11-05 18:40:15 +08:00
parent b533930bad
commit 5c7cc9e22c
+1 -1
View File
@@ -55,7 +55,7 @@ def train_logreg(X, y, other_params=None):
z = np.dot(X, weights) z = np.dot(X, weights)
predictions = sigmoid(z) 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 weights -= learning_rate * gradient