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)
相关推荐
Escalating_xu1 分钟前
【COZE实战】插件与知识库(三):让智能体会查资料,也会使用工具
开发语言·网络·人工智能·ai
蓝策电子5 分钟前
高大站房室内定位怎么布:AoA、RSSI 与 UWB 铁路枢纽选型解析
人工智能
车软学堂9 分钟前
Docker在隔离什么:namespace、cgroup、chroot三道墙
linux·python·docker·容器·车载系统·汽车·测试用例
长不大的杨瑞杰21 分钟前
Spring AI 企业级 RAG 实战:检索、重排、结构化输出与提示注入防护
java·人工智能·spring·llm·rag·springai
大模型真好玩21 分钟前
DSH+LLM Wiki 个人知识库应用开发实战(一)——回顾 LLM Wiki(原理篇)
人工智能·agent·deepseek
海宇数据26 分钟前
零信任架构实战:基于海宇对外投资历史查询服务构建自动化并购标的排查网关
大数据·人工智能·架构·自动化
ARM+FPGA+AI工业主板定制专家32 分钟前
车载边缘计算平台:Jetson 加固整机在自动驾驶感知中的应用
人工智能·自动驾驶·边缘计算
愤怒火龙果44 分钟前
AI 观察 02|安全的黑暗时代:Cognition 斯科特·吴访谈要点与 2026 年信息汇总
人工智能·安全·网络安全
xwz小王子1 小时前
Nature Sensors:把纳升液滴变成会“看“会“想“的机器人,比色检测自己优化
人工智能·机器人
zhanghongyi_cpp1 小时前
第4章 学习自测
python·学习