当前位置:网站首页>Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()
Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()
2022-07-07 16:03:00 【Pig man with small bottle cap】
torch.mul()
The functionality : Pair by pair input and other Multiply the corresponding elements in .
This operation supports broadcasting , therefore input and other Both can be tensors or numbers
import torch
a = torch.randn((1,2))
b = torch.randn((2,1))
print(a,b)
torch.mul(a,b)
torch.multiply()
torch.mul() The nickname
torch.matmul()
matmul You can do tensor multiplication , The input can be high-dimensional .
torch.dot()
The functionality : Calculation input and output Dot product of , This function requires input and output Must be a one-dimensional tensor ( Its shape There is only one value in the property )! And the number of elements of both is required to be the same !
import torch
x = torch.Tensor([1,2])
y = torch.Tensor([3,4])
z = torch.dot(x,y)
z
torch.mm()
The functionality : Realize matrix multiplication in Linear Algebra (matrix multiplication):(n×m) × (m×p) = (n×p) .
This function does not allow broadcasting !
import torch
x = torch.randn((3,4))
y = torch.randn((4,5))
z = torch.mm(x,y)
z
torch.mv()
The functionality : Realize matrix and vector (matrix × vector) Multiplication of , requirement input The shape of is n×m,output by torch.Size([m]) One dimension of tensor.
import torch
x = torch.randn((3,4))
y = torch.randn(4)
z = torch.mv(x,y)
z
边栏推荐
- postman生成时间戳,未来时间戳
- Iterator and for of.. loop
- 2022第四届中国(济南)国际智慧养老产业展览会,山东老博会
- The inevitable trend of the intelligent development of ankerui power grid is that microcomputer protection devices are used in power systems
- Bidding announcement: Panjin people's Hospital Panjin hospital database maintenance project
- 航天宏图信息中标乌鲁木齐某单位数据库系统研发项目
- webgl_ Enter the three-dimensional world (1)
- [wechat applet] Chapter (5): basic API interface of wechat applet
- There are many ways to realize the pause function in JS
- L'application à l'échelle de la normalisation mature des produits ai des compagnies maritimes, cimc, leader mondial de l'intelligence artificielle portuaire et maritime / intelligence artificielle des
猜你喜欢
Three. JS introductory learning notes 11:three JS group composite object
webgl_ Enter the three-dimensional world (2)
webgl_ Graphic transformation (rotation, translation, zoom)
LeetCode2_ Add two numbers
Virtual memory, physical memory /ram what
深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
10 schemes to ensure interface data security
持续创作,还得靠它!
The unity vector rotates at a point
随机推荐
Three. JS introductory learning notes 11:three JS group composite object
Regular expression string
numpy--疫情数据分析案例
深度之眼(六)——矩阵的逆(附:logistic模型一些想法)
Three. JS introductory learning notes 08:orbitcontrols JS plug-in - mouse control model rotation, zoom in, zoom out, translation, etc
Annexb and avcc are two methods of data segmentation in decoding
Three. JS introductory learning notes 10:three JS grid
Unity drawing plug-in = = [support the update of the original atlas]
Bidding announcement: Panjin people's Hospital Panjin hospital database maintenance project
Simple understanding and application of TS generics
Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
A wave of open source notebooks is coming
Use moviepy Editor clips videos and intercepts video clips in batches
Three. JS introductory learning notes 03: perspective projection camera
You Yuxi, coming!
leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
markdown公式编辑教程
The "go to definition" in VS2010 does not respond or prompts the solution of "symbol not found"
Shader Language
Wireless sensor networks -- ZigBee and 6LoWPAN