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)
相关推荐
元Y亨H3 分钟前
Pandas 解析 Excel 导致的内存溢出(MemoryError)
python·excel
爱研究的小梁13 分钟前
乾元通聚合路由及管理平台支持全面适配信创
网络·人工智能·信息与通信
水如烟33 分钟前
孤能子视角:智能系统的持续学习——从关系场存续到模块化生长
人工智能
做一个码农都是奢望35 分钟前
0722 LLM及其科研进展
人工智能
饼饼学习空间智能44 分钟前
2026数字孪生国产化进入“交付验证期”:五类头部企业能力与项目选型分析
人工智能
金銀銅鐵1 小时前
[Python] 用 turtle 来绘制瑞典国旗
python
Albert Edison1 小时前
【GUI 自动化测试】Pywinauto 常见操作
自动化测试·python·pywinauto
海兰1 小时前
【高速缓存】RedisVL为文本生成嵌入向量实践指南
人工智能·python·机器学习
2601_955760071 小时前
如何用 Claude Opus 5 API 批量扩展长尾关键词和文章选题
前端·python·搜索引擎
user-猴子1 小时前
让网页“活”过来 —— 用AI打造会自主学习的动态知识图谱
人工智能·学习·知识图谱