generated from LufsX/Experiment-LogReg
This commit is contained in:
+1
-1
@@ -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.01, iterations=2000, batch_size=64, reg_lambda=0.01):
|
def train_logreg(X, y, learning_rate=0.01, 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 # 初始化权重
|
||||||
|
|||||||
Reference in New Issue
Block a user