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)
相关推荐
开开心心就好19 小时前
图片格式转换工具,右键菜单一键转换简化
linux·运维·服务器·python·django·pdf·1024程序员节
骥龙19 小时前
1.2下、工欲善其事:物联网安全研究环境搭建指南
python·物联网·安全
GISer_Jing19 小时前
AI开发实战:从零搭建智能应用
人工智能·prompt·aigc
WZGL123019 小时前
智慧养老方兴未艾,“AI+养老”让银龄老人晚年更美好
大数据·人工智能·物联网·生活·智能家居
狼爷19 小时前
一文看懂 AI 世界里的新黑话Skills、MCP、Projects、Prompts
人工智能·openai·ai编程
疾风sxp19 小时前
nl2sql技术实现自动sql生成之langchain4j SqlDatabaseContentRetriever
java·人工智能·langchain4j
DisonTangor19 小时前
阿里Qwen开源Qwen3-VL-Embedding 和 Qwen3-VL-Reranker
人工智能·搜索引擎·开源·aigc·embedding
其美杰布-富贵-李19 小时前
深度学习中的 tmux
服务器·人工智能·深度学习·tmux
<-->19 小时前
deepspeed vs vllm
人工智能
Lxinccode19 小时前
BUG(20) : response.text耗时很久, linux耗时十几秒, Windows耗时零点几秒
python·bug·requests·response.text·response.text慢