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)
相关推荐
量化分析码农7 分钟前
【Python量化趋势跟踪实战 01】均线多头排列就是趋势开始吗:过滤与确认
python
用户2986985301410 分钟前
Python 实战:把代码写入 Word 文档的两种实现方式
后端·python·api
小小张说故事13 分钟前
Python 里 pickle 到底存了什么:拆开 __reduce__、__getstate__ 和那串能执行代码的字节码
python
reasonsummer23 分钟前
【教学类-150-03】20261108蝴蝶连连看html(一页2个版面、3个版面)
python·html
Elastic 中国社区官方博客25 分钟前
更少的位数,相同的召回率:DiskBBQ 更保守的自动校准扫描
大数据·运维·开发语言·人工智能·elasticsearch·搜索引擎
程序员cxuan31 分钟前
再见了 Typora
人工智能·后端·程序员
用户0190275816136 分钟前
用 Polars 快速分析 A 股 K 线:比 pandas 更快的列式处理
python
在所不辞兄38 分钟前
为什么在标签噪声场景下,识别双重下降拐点有助于防止模型记忆异常数据?
人工智能·深度学习·神经网络·机器学习
用户03321266636744 分钟前
使用 Python 轻松加密或解密 Excel 文档
python·excel
zzhongcy1 小时前
AI 的改变
人工智能