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)
相关推荐
IT_陈寒1 分钟前
Vite的静态资源打包让我熬夜到三点,这坑千万别跳
前端·人工智能·后端
玩转AI不是事1 小时前
用IndexedDB做AI对话离线缓存实战
人工智能
学测绘的小杨1 小时前
CompassFusion:一个从 GNSS 到 GNSS/INS 组合导航的独立工程包
python
Asize1 小时前
多模态生图:从 Vite 工程化到前端调用 Qwen Image
javascript·人工智能·后端
MobotStone1 小时前
AI项目越多,为什么越容易失控
人工智能·aigc
十有八七1 小时前
AI时代的置身X内
前端·人工智能
Lkstar2 小时前
A2A协议深度解析|Agent2Agent通信标准,智能体互联网的"HTTP"
人工智能·llm
百度Geek说2 小时前
当代码越来越便宜,什么在变贵?
人工智能
橘子星2 小时前
LLM 无状态架构实践:从原理到代码落地
前端·javascript·人工智能
召钱熏2 小时前
裸聊可用 ≠ 工作流可用:Gemma4 12B 接入 Claude Code 的真实踩坑复盘
人工智能