提交 a1ca6130 编写于 作者: R root

Sat Oct 11 11:06:00 CST 2025 inscode

上级 6ac9ba8a
...@@ -135,4 +135,4 @@ $RECYCLE.BIN/ ...@@ -135,4 +135,4 @@ $RECYCLE.BIN/
.DS_Store? .DS_Store?
._* ._*
.Spotlight-V100 .Spotlight-V100
.Trashes .Trashes._logger_
\ No newline at end of file
import torch
import numpy as np import numpy as np
np_array = np.array([1, 2, 3]) # 定义矩阵 A 和向量 b
tensor = torch.from_numpy(np_array) A = np.array([[1, 1], [1, 2], [1, 3]]) # 设计矩阵(3x2)
print(tensor) b = np.array([1, 2, 2]) # 观测值(3x1)
\ No newline at end of file
# 求解最小二乘问题
x, residuals, rank, singular_values = np.linalg.lstsq(A, b, rcond=None)
print("最优解 x:", x)
print("残差平方和:", residuals)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册