当前位置:网站首页>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
边栏推荐
- Numpy -- data cleaning
- 无线传感器网络--ZigBee和6LoWPAN
- 通知Notification使用全解析
- ./ Functions of configure, make and make install
- How does geojson data merge the boundaries of regions?
- U3D_ Infinite Bessel curve
- 安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是
- Three. JS introductory learning notes 15: threejs frame animation module
- Webgl texture
- 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
猜你喜欢
Step by step monitoring platform ZABBIX
2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
Three. JS introductory learning notes 00: coordinate system, camera (temporarily understood)
Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"
神经网络c语言中的指针是怎么回事
Unity3D_ Class fishing project, bullet rebound effect is achieved
SPI master RX time out interrupt
Application example of infinite list [uigridview]
星瑞格数据库入围“2021年度福建省信息技术应用创新典型解决方案”
随机推荐
A wave of open source notebooks is coming
Clang compile link ffmpeg FAQ
leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
Three. JS introductory learning notes 04: external model import - no material obj model
Asynchronous application of generator function
Bidding announcement: Panjin people's Hospital Panjin hospital database maintenance project
【花雕体验】15 尝试搭建Beetle ESP32 C3之Arduino开发环境
Postman generate timestamp, future timestamp
Numpy -- epidemic data analysis case
Three. Introduction to JS learning notes 17: mouse control of 3D model rotation of JSON file
The "go to definition" in VS2010 does not respond or prompts the solution of "symbol not found"
有钱人买房就是不一样
通知Notification使用全解析
Mesh merging under ue4/ue5 runtime
Plate - forme de surveillance par étapes zabbix
2022第四届中国(济南)国际智慧养老产业展览会,山东老博会
Numpy -- data cleaning
招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
121. 买卖股票的最佳时机
SysOM 案例解析:消失的内存都去哪了 !| 龙蜥技术