当前位置:网站首页>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
边栏推荐
- Three. JS introductory learning notes 13: animation learning
- Three singleton modes of unity (hungry man, lazy man, monobehavior)
- What about the pointer in neural network C language
- The "go to definition" in VS2010 does not respond or prompts the solution of "symbol not found"
- Ue4/ue5 multi thread development attachment plug-in download address
- Webcodecs parameter settings -avc1.42e01e meaning
- Particle effect for ugui
- You Yuxi, coming!
- C4D learning notes 1- animation - animation key frames
- Plate - forme de surveillance par étapes zabbix
猜你喜欢
![Application example of infinite list [uigridview]](/img/11/3be1c63680e6de8f068e79690ecf12.jpg)
Application example of infinite list [uigridview]

Dotween -- ease function

Shandong old age Expo, 2022 China smart elderly care exhibition, smart elderly care and aging technology exhibition

Three. JS introductory learning notes 00: coordinate system, camera (temporarily understood)

AE learning 02: timeline

Rongyun won the 2022 China Xinchuang digital office portal excellence product award!

Asynchronous application of generator function
![Unity drawing plug-in = = [support the update of the original atlas]](/img/b0/92114ffb1f168a1f27125db46c6797.jpg)
Unity drawing plug-in = = [support the update of the original atlas]

20th anniversary of agile: a failed uprising

Plate - forme de surveillance par étapes zabbix
随机推荐
Numpy -- epidemic data analysis case
航天宏图信息中标乌鲁木齐某单位数据库系统研发项目
nodejs package. JSON version number ^ and~
numpy--疫情数据分析案例
Three. JS introductory learning notes 07: external model import -c4d to JSON file for web pages -fbx import
Strengthen real-time data management, and the British software helps the security construction of the medical insurance platform
Three. JS introductory learning notes 00: coordinate system, camera (temporarily understood)
OpenGL's distinction and understanding of VAO, VBO and EBO
分步式监控平台zabbix
Ue4/ue5 multi thread development attachment plug-in download address
Use moviepy Editor clips videos and intercepts video clips in batches
Dotween -- ease function
Unity drawing plug-in = = [support the update of the original atlas]
AE learning 02: timeline
Three. JS introductory learning notes 19: how to import FBX static model
Plate - forme de surveillance par étapes zabbix
招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
神经网络c语言中的指针是怎么回事
持续创作,还得靠它!
Simple understanding and application of TS generics