当前位置:网站首页>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
边栏推荐
- Migration and reprint
- How to deploy the super signature distribution platform system?
- Detailed explanation of Cocos creator 2.4.0 rendering process
- Three singleton modes of unity (hungry man, lazy man, monobehavior)
- Excessive dependence on subsidies, difficult collection of key customers, and how strong is the potential to reach the dream of "the first share of domestic databases"?
- numpy--疫情数据分析案例
- Annexb and avcc are two methods of data segmentation in decoding
- 分步式监控平台zabbix
- 航运船公司人工智能AI产品成熟化标准化规模应用,全球港航人工智能/集装箱人工智能领军者CIMC中集飞瞳,打造国际航运智能化标杆
- OpenGL's distinction and understanding of VAO, VBO and EBO
猜你喜欢

Use of SVN

【微信小程序】Chapter(5):微信小程序基础API接口

The unity vector rotates at a point

SPI master rx time out中断

When opening the system window under UE4 shipping, the problem of crash is attached with the plug-in download address

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

Getting started with webgl (2)

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

Cocos creator collision and collision callback do not take effect

Streaming end, server end, player end
随机推荐
The download button and debug button in keil are grayed out
Three. JS introductory learning notes 0: illustration of how webgl and threejs work
The rebound problem of using Scrollview in cocos Creator
Getting started with webgl (3)
【微信小程序】Chapter(5):微信小程序基础API接口
Super simple and fully automated generation super signature system (cloud Xiaoduo minclouds.com cloud service instance), free application in-house test app distribution and hosting platform, maintenan
Shipping companies' AI products are mature, standardized and applied on a large scale. CIMC, the global leader in port and shipping AI / container AI, has built a benchmark for international shipping
Matlab experience summary
How to create Apple Developer personal account P8 certificate
nodejs package. JSON version number ^ and~
Whole process analysis of unity3d rendering pipeline
Share the technical details of super signature system construction
Three. JS introductory learning notes 10:three JS grid
UE4 exports the picture + text combination diagram through ucanvasrendertarget2d
Eye of depth (VI) -- inverse of matrix (attachment: some ideas of logistic model)
Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models
Async and await
Regular expression string
Points for attention in porting gd32 F4 series programs to gd32 F3 series
航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆