2023-10-10 09:42:31 +08:00

24 lines
420 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)