当前位置:网站首页>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
边栏推荐
猜你喜欢

LeetCode2_ Add two numbers

TS as a general cache method

Three. JS introductory learning notes 10:three JS grid

过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?

numpy---基础学习笔记

LeetCode3_ Longest substring without duplicate characters

Good news! Kelan sundb database and Hongshu technology privacy data protection management software complete compatibility adaptation

10 schemes to ensure interface data security

讲师征集令 | Apache SeaTunnel(Incubating) Meetup 分享嘉宾火热招募中!

Mysql database basic operation DQL basic query
随机推荐
深度之眼(六)——矩阵的逆(附:logistic模型一些想法)
torch.numel作用
Mysql database backup script
Use moviepy Editor clips videos and intercepts video clips in batches
Iterator and for of.. loop
Wireless sensor networks -- ZigBee and 6LoWPAN
47_Opencv中的轮廓查找 cv::findContours()
【微信小程序】Chapter(5):微信小程序基础API接口
numpy---基础学习笔记
强化实时数据管理,英方软件助力医保平台安全建设
PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
webgl_ Graphic transformation (rotation, translation, zoom)
Three. JS introductory learning notes 18: how to export JSON files with Blender
The "go to definition" in VS2010 does not respond or prompts the solution of "symbol not found"
nodejs package. JSON version number ^ and~
[excelexport], Excel to Lua, JSON, XML development tool
2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
C Alibaba cloud OSS file upload, download and other operations (unity is available)
Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)