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

This commit is contained in:
2024-11-10 14:49:23 +08:00
parent 9b8722ffc7
commit 1bb3af97a9
+1 -1
View File
@@ -32,7 +32,7 @@ def sigmoid(z):
"""Sigmoid 激活函数。""" """Sigmoid 激活函数。"""
return 1.0 / (1 + np.exp(-z)) return 1.0 / (1 + np.exp(-z))
def train_logreg(X, y, learning_rate=0.05, iterations=1500, batch_size=64, reg_lambda=0.01): def train_logreg(X, y, learning_rate=0.001, iterations=1500, batch_size=64, reg_lambda=0.01):
"""训练逻辑回归模型的函数,使用梯度下降算法。""" """训练逻辑回归模型的函数,使用梯度下降算法。"""
m, n = X.shape m, n = X.shape
weights = np.random.randn(n) * 0.01 # 初始化权重 weights = np.random.randn(n) * 0.01 # 初始化权重