当前位置:网站首页>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
边栏推荐
- How to deploy the super signature distribution platform system?
- Yunxiaoduo software internal test distribution test platform description document
- Detailed explanation of unity hot update knowledge points and introduction to common solution principles
- C4D learning notes 3- animation - animation rendering process case
- Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
- Apache Doris just "graduated": why should we pay attention to this kind of SQL data warehouse?
- 强化实时数据管理,英方软件助力医保平台安全建设
- SPI master RX time out interrupt
- Share the technical details of super signature system construction
- nodejs package. JSON version number ^ and~
猜你喜欢

OpenGL's distinction and understanding of VAO, VBO and EBO

分步式监控平台zabbix

2022第四届中国(济南)国际智慧养老产业展览会,山东老博会

Yunxiaoduo software internal test distribution test platform description document

C4D learning notes 2- animation - timeline and time function

webgl_ Enter the three-dimensional world (2)

Gd32 F3 pin mapping problem SW interface cannot be burned

航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆

航运船公司人工智能AI产品成熟化标准化规模应用,全球港航人工智能/集装箱人工智能领军者CIMC中集飞瞳,打造国际航运智能化标杆

Getting started with webgl (4)
随机推荐
Create lib Library in keil and use lib Library
nodejs package. JSON version number ^ and~
[wechat applet] Chapter (5): basic API interface of wechat applet
Summary of knowledge points of xlua hot update solution
Super signature principle (fully automated super signature) [Yun Xiaoduo]
安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是
A wave of open source notebooks is coming
[excelexport], Excel to Lua, JSON, XML development tool
Spin animation of Cocos performance optimization
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
Syntaxhighlight highlights the right scroll bar
LeetCode1_ Sum of two numbers
Shader_ Animation sequence frame
Wireless sensor networks -- ZigBee and 6LoWPAN
Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
星瑞格数据库入围“2021年度福建省信息技术应用创新典型解决方案”
Using eating in cocos Creator
Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
Detailed explanation of Cocos creator 2.4.0 rendering process
Shader Language