pytorch@操作符

bash 复制代码
import torch

# Define two tensors (matrices)
A = torch.tensor([[1, 2], [3, 4]])
B = torch.tensor([[5, 6], [7, 8]])

# Perform matrix multiplication using @ operator
C = A @ B

print(C)

print(torch.matmul(A,B))

print(torch.mm(A,B))

example2

bash 复制代码
import torch
import numpy as np 
m = 5
p = 3 
n = 4 

# Define two tensors (matrices)
A = torch.tensor(np.random.randn(m,p))
B = torch.tensor(np.random.randn(p,n))

# Perform matrix multiplication using @ operator
C = A @ B

print(C)

print(torch.matmul(A,B))

print(torch.mm(A,B))![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/7ed9ce4cada04ce7943a7c743316f461.png)
相关推荐
就牙白34 分钟前
中科方德服务器打包RPM
linux·python
wuyuanshun36 分钟前
LangGraph原理逻辑-LangGraph接入MCP(三)
人工智能·ai
IT_陈寒36 分钟前
React的useEffect为什么经常执行两次?
前端·人工智能·后端
武子康41 分钟前
GitHub Models 7-30 退役全拆:Inventory + Capability Probe + Shadow Traffic + Brownout
人工智能·github·github copilot
larance1 小时前
机器学习特征预处理之处理数据不平衡
人工智能·机器学习
视***间1 小时前
端侧20B级推理标杆:视程空间Pandora,让GPT-OSS 20B在边缘原生落地
人工智能·gpt·大模型·本地部署·大模型本地部署·视程空间
2601_954971131 小时前
经济统计学本科毕业,如何开启职业新篇章?
人工智能
Summer-Bright1 小时前
深度 | Kimi K3 48 小时设计芯片:EDA 行业真的会被 AI 颠覆吗?
人工智能·ai·自然语言处理·agi
xing-xing1 小时前
魔搭社区(ModelScope)下载模型文件
python·jupyter·llm
东坡肘子1 小时前
当灵感跑在了结果前面 -- 肘子的 Swift 周报 #145
人工智能·swiftui·swift