当前位置:网站首页>PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
2022-07-07 13:49:00 【小瓶盖的猪猪侠】
torch.mul()
函数功能:逐个对 input 和 other 中对应的元素相乘。
本操作支持广播,因此 input 和 other 均可以是张量或者数字
import torch
a = torch.randn((1,2))
b = torch.randn((2,1))
print(a,b)
torch.mul(a,b)
torch.multiply()
torch.mul() 的别称
torch.matmul()
matmul可以进行张量乘法, 输入可以是高维.
torch.dot()
函数功能:计算 input 和 output 的点乘,此函数要求 input 和 output 都必须是一维的张量(其 shape 属性中只有一个值)!并且要求两者元素个数相同!
import torch
x = torch.Tensor([1,2])
y = torch.Tensor([3,4])
z = torch.dot(x,y)
z
torch.mm()
函数功能:实现线性代数中的矩阵乘法(matrix multiplication):(n×m) × (m×p) = (n×p) 。
本函数不允许广播!
import torch
x = torch.randn((3,4))
y = torch.randn((4,5))
z = torch.mm(x,y)
z
torch.mv()
函数功能:实现矩阵和向量(matrix × vector)的乘法,要求 input 的形状为 n×m,output 为 torch.Size([m])的一维 tensor.
import torch
x = torch.randn((3,4))
y = torch.randn(4)
z = torch.mv(x,y)
z
边栏推荐
- Three. JS introductory learning notes 05: external model import -c4d into JSON file for web pages
- 有钱人买房就是不一样
- numpy--疫情数据分析案例
- Asynchronous application of generator function
- Three. JS introduction learning notes 12: the model moves along any trajectory line
- The "go to definition" in VS2010 does not respond or prompts the solution of "symbol not found"
- After UE4 is packaged, mesh has no material problem
- 航天宏图信息中标乌鲁木齐某单位数据库系统研发项目
- Regular expression string
- Use of SVN
猜你喜欢
Whole process analysis of unity3d rendering pipeline
持续创作,还得靠它!
【微信小程序】Chapter(5):微信小程序基础API接口
航运船公司人工智能AI产品成熟化标准化规模应用,全球港航人工智能/集装箱人工智能领军者CIMC中集飞瞳,打造国际航运智能化标杆
融云斩获 2022 中国信创数字化办公门户卓越产品奖!
LeetCode1_ Sum of two numbers
Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models
航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆
JS array foreach source code parsing
分步式监控平台zabbix
随机推荐
Clang compile link ffmpeg FAQ
航天宏图信息中标乌鲁木齐某单位数据库系统研发项目
Share the technical details of super signature system construction
Three. JS introductory learning notes 10:three JS grid
LeetCode2_ Add two numbers
Introduction to pyGame games
C4D learning notes 1- animation - animation key frames
Learn good-looking custom scroll bars in 1 minute
喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
Vite path alias @ configuration
TCP framework___ Unity
Mesh merging under ue4/ue5 runtime
webgl_ Enter the three-dimensional world (2)
Syntaxhighlight highlights the right scroll bar
Is it reliable to open an account on Tongda letter with your mobile phone? Is there any potential safety hazard in such stock speculation
保证接口数据安全的10种方案
融云斩获 2022 中国信创数字化办公门户卓越产品奖!
./ Functions of configure, make and make install
招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
A link opens the applet code. After compilation, it is easy to understand