当前位置:网站首页>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
边栏推荐
- Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
- C4D learning notes 2- animation - timeline and time function
- 融云斩获 2022 中国信创数字化办公门户卓越产品奖!
- Numpy -- epidemic data analysis case
- C4D learning notes 1- animation - animation key frames
- Please supervise the 2022 plan
- U3D_ Infinite Bessel curve
- How does geojson data merge the boundaries of regions?
- 用手机在通达信上开户靠谱吗?这样炒股有没有什么安全隐患
- Mysql database backup script
猜你喜欢

numpy---基础学习笔记

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

A wave of open source notebooks is coming

webgl_ Enter the three-dimensional world (1)

UE4 exports the picture + text combination diagram through ucanvasrendertarget2d

Ue4/ue5 multi thread development attachment plug-in download address

喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配

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

Keil5 does not support online simulation of STM32 F0 series

SPI master RX time out interrupt
随机推荐
深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
20th anniversary of agile: a failed uprising
Regular expression string
./ Functions of configure, make and make install
山东老博会,2022中国智慧养老展会,智能化养老、适老科技展
Three. JS introductory learning notes 07: external model import -c4d to JSON file for web pages -fbx import
Three. JS introduction learning notes 12: the model moves along any trajectory line
2022山东智慧养老展,适老穿戴设备展,养老展,山东老博会
Migration and reprint
Unity3D_ Class fishing project, bullet rebound effect is achieved
Super signature principle (fully automated super signature) [Yun Xiaoduo]
SPI master RX time out interrupt
Clang compile link ffmpeg FAQ
Three singleton modes of unity (hungry man, lazy man, monobehavior)
航运船公司人工智能AI产品成熟化标准化规模应用,全球港航人工智能/集装箱人工智能领军者CIMC中集飞瞳,打造国际航运智能化标杆
Summary of knowledge points of xlua hot update solution
Detailed explanation of Cocos creator 2.4.0 rendering process
It's different for rich people to buy a house
[wechat applet] Chapter (5): basic API interface of wechat applet