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)
相关推荐
智鸟科技GemeOpen开发者智能设备5 分钟前
MQTT智能插座GSPM1B2 · 开发者实战指南
java·开发语言·python·物联网
Thinker QAQ6 分钟前
并发编程(七):volatile——从语言规则到 CPU
java·python·go·并发编程·volatile·memory model
Fluxproxy7 分钟前
Python BeautifulSoup4 超全实战教程|解决网页乱码、标签匹配、层级查找、数据提取难题
开发语言·python
7yewh9 分钟前
SLAM 从视觉里程计到建图(6)
数据结构·人工智能·机器人·自动驾驶·嵌入式
勤劳X码农11 分钟前
2026年AI配音做职场视频怎么选?
人工智能·音视频
YOLO数据集集合12 分钟前
玉米雄穗目标检测数据集 | 玉米雄穗 作物表型 智慧农业 无人机巡检 小样本检测9142期
人工智能·目标检测·无人机·玉米·玉米雄蕊·玉米雄穗
weixin_4045512419 分钟前
AI Native 架构建议:从零开始以 AI 为核心构建系统
人工智能·架构
蝶依斓(湖南)全案整装22 分钟前
整装行业长尾需求内容矩阵搭建方法:从五个维度拆解用户需求
大数据·人工智能·矩阵
半条_虫24 分钟前
SAI(Shell AI Agent) 使用说明
人工智能
蜗牛互联网27 分钟前
从GitHub动态工作流理解确定性编排与Agent判断边界
java·人工智能·后端·github