请用python写一段logistic方程组求解代码
时间: 2023-03-10 12:58:17 浏览: 108
import numpy as npdef logistic_solver(A, b):
# 获取A的维数
m, n = A.shape
# 初始化变量
X = np.zeros(shape=(n, 1))
# 迭代计算
for _ in range(1000):
for i in range(n):
sum_val = 0
for j in range(m):
sum_val += A[j][i] * X[j]
X[i] = 1/(1+np.exp(-sum_val + b[i]))
return X
if __name__ == "__main__":
A = np.array([[1,2,3], [2,3,4], [3,4,5]])
b = np.array([[1], [2], [3]])
print(logistic_solver(A, b))
阅读全文