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)
相关推荐
AI源码13 小时前
AI在线问诊平台
人工智能
心静财富之门13 小时前
Python 数据共享四种方案完整实例(同进程 / JSON / Redis / HTTP)
数据库·python·oracle
一只爱撸猫的程序猿13 小时前
当任何人都能生成一万行代码:什么变得稀缺
人工智能·后端·程序员
读完一本书14 小时前
AI 生成的图,为什么一眼就能看出是 AI?5 个破绽
人工智能·aigc
Potato_土豆14 小时前
MCP Server 接入多个 AI 客户端:配置差异与 10 个真实踩坑
人工智能·后端·ai编程
2601_9620710014 小时前
Grok 4.6 与 Kimi K2.5 对比:编程、长文本与 API 成本怎么选?
人工智能
王仔小奶14 小时前
慢SQL治理与性能调优:DBA如何用Shell/Python提升运维效率?
python·sql·dba
秦先生在广东14 小时前
用4条规矩驯服AI写代码
人工智能
用户03321266636714 小时前
使用 Python 快速在 PowerPoint 中生成表格【教程】
python
LeoLi63814 小时前
随机应变,不是见招拆招:AI 干 6 倍工时之后,我把它做成了三层降级链路
人工智能·程序员