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)
相关推荐
MediaTea9 分钟前
Pandas 操作指南(二):数据选取与条件筛选
人工智能·python·机器学习·数据挖掘·pandas
萤萤七悬14 分钟前
【人工智能训练师3级】考试准备(2026)四、简答题 1.2.1-1.2.5
人工智能
小陈工14 分钟前
Python Web开发入门(十二):使用Flask-RESTful构建API——让后端开发更优雅
开发语言·前端·python·安全·oracle·flask·restful
永霖光电_UVLED16 分钟前
当前 AR 眼镜显示技术面临的“人类视觉因素”瓶颈与半导体全息调制器
人工智能·架构
MediaTea17 分钟前
AI 术语通俗词典:协方差
人工智能
无心水17 分钟前
20、Spring陷阱:Feign AOP切面为何失效?配置优先级如何“劫持”你的设置?
java·开发语言·后端·python·spring·java.time·java时间处理
chenglin01620 分钟前
AI应用性能优化与生产环境部署
人工智能·性能优化
mit6.82420 分钟前
量子计算
人工智能
中金快讯20 分钟前
济民健康医疗服务占比提升至46%!业务结构调整初见成效
大数据·人工智能
南湖北漠24 分钟前
记录生活中的一件小事(佚名整理)
网络·人工智能·计算机网络·其他·安全·生活