diff --git a/function.py b/function.py index 51c9ddc..bcf192b 100644 --- a/function.py +++ b/function.py @@ -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