From 5c7cc9e22c2b9af8645a80c8d61dae4c7428a46c Mon Sep 17 00:00:00 2001 From: luderby <2339127037@qq.com> Date: Tue, 5 Nov 2024 18:40:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20function.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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