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

This commit is contained in:
wzy
2024-10-26 18:54:45 +08:00
parent 915bdbbaf7
commit 00eee29cf4
+1 -1
View File
@@ -30,7 +30,7 @@ name = "万子玉"
def sigmoid(z): def sigmoid(z):
return 1 / (1 + np.exp(-z)) return 1 / (1 + np.exp(-z))
def train_logreg(X, y, learning_rate=0.001, iterations=500, batch_size=16, initial_weights=np.zeros(n_features + 1)): def train_logreg(X, y, learning_rate=0.001, iterations=500, batch_size=16, initial_weights=None):
X = np.insert(X, 0, 1, axis=1) # 添加偏置项 X = np.insert(X, 0, 1, axis=1) # 添加偏置项
if initial_weights is None: if initial_weights is None:
weights = np.zeros(X.shape[1]) weights = np.zeros(X.shape[1])