当前位置:网站首页>PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
2022-07-07 13:49:00 【小瓶盖的猪猪侠】
torch.mul()
函数功能:逐个对 input 和 other 中对应的元素相乘。
本操作支持广播,因此 input 和 other 均可以是张量或者数字
import torch
a = torch.randn((1,2))
b = torch.randn((2,1))
print(a,b)
torch.mul(a,b)

torch.multiply()
torch.mul() 的别称
torch.matmul()
matmul可以进行张量乘法, 输入可以是高维.
torch.dot()
函数功能:计算 input 和 output 的点乘,此函数要求 input 和 output 都必须是一维的张量(其 shape 属性中只有一个值)!并且要求两者元素个数相同!
import torch
x = torch.Tensor([1,2])
y = torch.Tensor([3,4])
z = torch.dot(x,y)
z

torch.mm()
函数功能:实现线性代数中的矩阵乘法(matrix multiplication):(n×m) × (m×p) = (n×p) 。
本函数不允许广播!
import torch
x = torch.randn((3,4))
y = torch.randn((4,5))
z = torch.mm(x,y)
z

torch.mv()
函数功能:实现矩阵和向量(matrix × vector)的乘法,要求 input 的形状为 n×m,output 为 torch.Size([m])的一维 tensor.
import torch
x = torch.randn((3,4))
y = torch.randn(4)
z = torch.mv(x,y)
z
边栏推荐
- Three. JS introduction learning notes 12: the model moves along any trajectory line
- Mesh merging under ue4/ue5 runtime
- C4D learning notes 3- animation - animation rendering process case
- Three. JS introductory learning notes 07: external model import -c4d to JSON file for web pages -fbx import
- Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"
- Matlab experience summary
- Shader Language
- LeetCode2_ Add two numbers
- Postman generate timestamp, future timestamp
- 讲师征集令 | Apache SeaTunnel(Incubating) Meetup 分享嘉宾火热招募中!
猜你喜欢

强化实时数据管理,英方软件助力医保平台安全建设

After UE4 is packaged, mesh has no material problem
通知Notification使用全解析

numpy--疫情数据分析案例

Gd32 F3 pin mapping problem SW interface cannot be burned

LeetCode3_ Longest substring without duplicate characters

Spin animation of Cocos performance optimization

10 schemes to ensure interface data security

Numpy -- data cleaning

Eye of depth (VII) -- Elementary Transformation of matrix (attachment: explanation of some mathematical models)
随机推荐
Eye of depth (VI) -- inverse of matrix (attachment: some ideas of logistic model)
有钱人买房就是不一样
招标公告:盘锦市人民医院盘锦医院数据库维保项目
Keil5 does not support online simulation of STM32 F0 series
Mesh merging under ue4/ue5 runtime
Wireless sensor networks -- ZigBee and 6LoWPAN
AE learning 02: timeline
Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"
Share the technical details of super signature system construction
VS2005 strange breakpoint is invalid or member variable value cannot be viewed
webgl_ Graphic transformation (rotation, translation, zoom)
Three. JS introductory learning notes 11:three JS group composite object
Apache Doris just "graduated": why should we pay attention to this kind of SQL data warehouse?
Create lib Library in keil and use lib Library
Unity3D_ Class fishing project, bullet rebound effect is achieved
TCP framework___ Unity
Use moviepy Editor clips videos and intercepts video clips in batches
UE4 exports the picture + text combination diagram through ucanvasrendertarget2d
A JS script can be directly put into the browser to perform operations
postman生成时间戳,未来时间戳