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)
相关推荐
冬奇Lab11 小时前
每日一个开源项目(第140篇):AgentScope 2.0 - 阿里开源的生产级 Agent 框架
人工智能·开源·agent
冬奇Lab12 小时前
Skill 系列(04):Skill 指标体系——L1/L2/L3 三层监控,让质量下降有据可查
人工智能·开源·llm
IT_陈寒13 小时前
Vite的静态资源打包让我熬夜到三点,这坑千万别跳
前端·人工智能·后端
玩转AI不是事13 小时前
用IndexedDB做AI对话离线缓存实战
人工智能
学测绘的小杨14 小时前
CompassFusion:一个从 GNSS 到 GNSS/INS 组合导航的独立工程包
python
Asize14 小时前
多模态生图:从 Vite 工程化到前端调用 Qwen Image
javascript·人工智能·后端
MobotStone14 小时前
AI项目越多,为什么越容易失控
人工智能·aigc
十有八七14 小时前
AI时代的置身X内
前端·人工智能
Lkstar14 小时前
A2A协议深度解析|Agent2Agent通信标准,智能体互联网的"HTTP"
人工智能·llm
百度Geek说14 小时前
当代码越来越便宜,什么在变贵?
人工智能