first commit

This commit is contained in:
2023-10-10 09:42:31 +08:00
commit 175bf7b7da
12 changed files with 3102 additions and 0 deletions

23
Lab1/code/1.2.py Normal file
View File

@@ -0,0 +1,23 @@
import torch
mean = 0
stddev = 0.01
P = torch.normal(mean=mean, std=stddev, size=(3, 2))
Q = torch.normal(mean=mean, std=stddev, size=(4, 2))
print("矩阵 P:")
print(P)
print("矩阵 Q:")
print(Q)
# 对矩阵Q进行转置操作得到矩阵Q的转置Q^T
QT = Q.T
print("矩阵 QT:")
print(QT)
# 计算矩阵P和矩阵Q^T的矩阵相乘
result = torch.matmul(P, QT)
print("矩阵相乘的结果:")
print(result)