当前位置:网站首页>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
边栏推荐
- AE learning 01: AE complete project summary
- After UE4 is packaged, mesh has no material problem
- TCP framework___ Unity
- Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
- Three. JS introductory learning notes 11:three JS group composite object
- Syntax of generator function (state machine)
- 有钱人买房就是不一样
- 谈谈 SAP iRPA Studio 创建的本地项目的云端部署问题
- 持续创作,还得靠它!
- Notification uses full resolution
猜你喜欢

After UE4 is packaged, mesh has no material problem

numpy---基础学习笔记

Tkinter after how to refresh data and cancel refreshing

Dotween -- ease function

Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"

【花雕体验】15 尝试搭建Beetle ESP32 C3之Arduino开发环境

Webgl texture

Three. JS introductory learning notes 19: how to import FBX static model

Iterator and for of.. loop

Mesh merging under ue4/ue5 runtime
随机推荐
通知Notification使用全解析
20th anniversary of agile: a failed uprising
Mysql database basic operation DQL basic query
Numpy --- basic learning notes
Whole process analysis of unity3d rendering pipeline
Annexb and avcc are two methods of data segmentation in decoding
Bidding announcement: Panjin people's Hospital Panjin hospital database maintenance project
C4D learning notes 2- animation - timeline and time function
Mesh merging under ue4/ue5 runtime
过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?
Apache Doris just "graduated": why should we pay attention to this kind of SQL data warehouse?
融云斩获 2022 中国信创数字化办公门户卓越产品奖!
Virtual memory, physical memory /ram what
SPI master RX time out interrupt
深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
Cocos creator collision and collision callback do not take effect
Syntaxhighlight highlights the right scroll bar
TS as a general cache method
Bidding announcement: Fujian Rural Credit Union database audit system procurement project (re bidding)
Eye of depth (VI) -- inverse of matrix (attachment: some ideas of logistic model)