当前位置:网站首页>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
边栏推荐
- Plate - forme de surveillance par étapes zabbix
- Ue4/ue5 multi thread development attachment plug-in download address
- Three. JS introductory learning notes 15: threejs frame animation module
- There are many ways to realize the pause function in JS
- 过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?
- leetcode 241. Different Ways to Add Parentheses 为运算表达式设计优先级(中等)
- torch.numel作用
- 安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是
- Three. JS introductory learning notes 11:three JS group composite object
- nodejs package. JSON version number ^ and~
猜你喜欢

Three. JS introductory learning notes 18: how to export JSON files with Blender
![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]

Virtual memory, physical memory /ram what

2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo

无线传感器网络--ZigBee和6LoWPAN

Three. JS introductory learning notes 10:three JS grid

After UE4 is packaged, mesh has no material problem

Apache Doris just "graduated": why should we pay attention to this kind of SQL data warehouse?

SPI master RX time out interrupt

numpy--疫情数据分析案例
随机推荐
hellogolang
After UE4 is packaged, mesh has no material problem
谈谈 SAP iRPA Studio 创建的本地项目的云端部署问题
深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
How does geojson data merge the boundaries of regions?
It's different for rich people to buy a house
Asynchronous application of generator function
OpenGL's distinction and understanding of VAO, VBO and EBO
Three. JS introductory learning notes 0: illustration of how webgl and threejs work
Use moviepy Editor clips videos and intercepts video clips in batches
Three. JS introductory learning notes 13: animation learning
Three. JS introductory learning notes 10:three JS grid
How to implement backspace in shell
安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是
Three singleton modes of unity (hungry man, lazy man, monobehavior)
VS2005 strange breakpoint is invalid or member variable value cannot be viewed
Using eating in cocos Creator
Plate - forme de surveillance par étapes zabbix
121. 买卖股票的最佳时机
用手机在通达信上开户靠谱吗?这样炒股有没有什么安全隐患