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

This commit is contained in:
Wyy
2024-11-02 21:43:52 +08:00
parent d9b6dd8180
commit 8b8f14440f
+2 -4
View File
@@ -4,8 +4,7 @@ id = "202210423224"
name = "吴杨洋"
def sigmoid(z):
z = np.clip(z, -500, 500) # 限制 z 的值范围以避免溢出
return 1 / (1 + np.exp(-z))
return 1 / (1 + np.exp(-np.clip(z, -500, 500)))
def train_logreg(X, y, numIter=1000, learning_rate=0.01, lambda_reg=0.01, batch_size=64):
m, n = X.shape
@@ -55,8 +54,7 @@ def load_data(filepath):
data_number = len(y)
y_train = np.array([1 if y[j] == '2' or y[j] == '3' else 0 for j in range(data_number)])
X = np.array(data_list)
X_train = np.insert(X, 0, 1, axis=1) # 添加偏置项
return X_train, y_train
return X, y_train
def standardize(X):
mean = X.mean(axis=0)