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)
相关推荐
Tangyuewei1 分钟前
388 个 PR:AI 自主运维实测
运维·人工智能
逸Y 仙X3 分钟前
MCP(模型控制协议)完全指南:从核心概念到实战开发
python·大模型·llm·ai编程·mcp
OpenMiniServer9 分钟前
复利普化型社会——从关系协同走向产业协同
人工智能
大模型丫丫20 分钟前
检索增强生成(RAG)入门:原理、架构与实践
人工智能·rag
martindelophy28 分钟前
使用 Timeline Studio 制作 AI 视频二创:从高光分析、音乐卡点到 15 秒成片
人工智能·音视频
海兰32 分钟前
【插件】Logbook 插件完全指南(适配 Ubuntu 24.04)
linux·运维·人工智能·ubuntu·agent·openclaw
潘高34 分钟前
如何用 AI 做出高质量的 PPT
人工智能·ppt
云云只是个程序马喽39 分钟前
短剧/推文/AI创作变现小程序完整落地方案:自研vs成熟系统成本对比+全流程实现指南
人工智能·小程序
大厂码农老A41 分钟前
177K star,扒开DeepSeek Harness的营销,我看到了什么
人工智能·后端·deepseek
WILLF42 分钟前
前端视角:Python requests vs JS axios
前端·python