参考链接: mul(value) → Tensor
参考链接: torch.mul()

使用说明:

对两个张量进行逐元素乘法
Microsoft Windows [版本 10.0.18363.1256]
(c) 2019 Microsoft Corporation。保留所有权利。C:\Users\chenxuqi>conda activate ssd4pytorch1_2_0(ssd4pytorch1_2_0) C:\Users\chenxuqi>
(ssd4pytorch1_2_0) C:\Users\chenxuqi>python
Python 3.7.7 (default, May  6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.manual_seed(seed=20200910)
<torch._C.Generator object at 0x000002DDA5E6D330>
>>>
>>>
>>> a = torch.randn(3)
>>> a
tensor([ 0.2824, -0.3715,  0.9088])
>>> torch.mul(a, 2020.0910)
tensor([ 570.4512, -750.4310, 1835.8087])
>>>
>>>
>>>
>>> torch.manual_seed(seed=20200910)
<torch._C.Generator object at 0x000002DDA5E6D330>
>>>
>>> a = torch.randn(4, 1)
>>> b = torch.randn(1, 4)
>>> a
tensor([[ 0.2824],[-0.3715],[ 0.9088],[-1.7601]])
>>> b
tensor([[-0.1806,  2.0937,  1.0406, -1.7651]])
>>> torch.mul(a, b)
tensor([[-0.0510,  0.5912,  0.2939, -0.4985],[ 0.0671, -0.7778, -0.3866,  0.6557],[-0.1641,  1.9027,  0.9457, -1.6041],[ 0.3179, -3.6851, -1.8316,  3.1069]])
>>>
>>> torch.mul(b, a)
tensor([[-0.0510,  0.5912,  0.2939, -0.4985],[ 0.0671, -0.7778, -0.3866,  0.6557],[-0.1641,  1.9027,  0.9457, -1.6041],[ 0.3179, -3.6851, -1.8316,  3.1069]])
>>>
>>>
>>>

torch.mul()函数的使用相关推荐

  1. PyTorch疑难杂症(1)——torch.matmul()函数用法总结

    目录 一.函数介绍 二.常见用法 2.1 两个一维向量的乘积运算 2.2 两个二维矩阵的乘积运算 2.3 一个一维向量和一个二维矩阵的乘积运算 2.4 一个二维矩阵和一个一维向量的乘积运算 2.5 其 ...

  2. tensor和numpy中的乘法运算,如torch.mul()和torch.sum()函数的用法

    1.区分一下张量的几种乘法 主要是在看代码时,这个**@**的作用记录一下 numpy或者tensor中点乘使用*或者np.multiply(), np.dot(), np.matmul(), ten ...

  3. PyTorch 笔记(05)— Tensor 基本运算(torch.abs、torch.add、torch.clamp、torch.div、torch.mul、torch.pow等)

    1. 函数汇总 Tensor 的基本运算会对 tensor 的每一个元素进行操作,此类操作的输入与输出形状一致,常用操作见下表所示. 对于很多操作,例如 div.mul.pow.fmod.等, PyT ...

  4. torch中的几种乘法。torch.mm, torch.mul, torch.matmul

    一.点乘 点乘都是broadcast的,可以用torch.mul(a, b)实现,也可以直接用*实现. a = torch.ones(3,4) a tensor([[1., 1., 1., 1.], ...

  5. torch中乘法整理,*torch.mul()torch.mv()torch.mm()torch.dot()@torch.mutmal()

    目录 *位置乘 torch.mul():数乘 torch.mv():矩阵向量乘法 torch.mm() 矩阵乘法 torch.dot() 点乘积 @操作 torch.matmul() *位置乘 符号* ...

  6. pytorch中torch.mul、torch.mm/torch.bmm、torch.matmul的区别

    预备知识:矩阵的各种乘积 三者对比 torch.mul: 两个输入按元素相乘,内积 分两种情况,默认其中一个是tensor 另一个也是tensor,那么两者就要符合broadcasedt的规则 另一个 ...

  7. 【Pytorch学习】torch.mm()torch.matmul()和torch.mul()以及torch.spmm()

    目录 1 引言 2 torch.mul(a, b) 3 torch.mm(a, b) 4 torch.matmul() 5 torch.spmm() 参考文献 1 引言   做深度学习过程中免不了使用 ...

  8. Pytorch矩阵乘法之torch.mul() 、 torch.mm() 及torch.matmul()的区别

    torch.mul() . torch.mm() 及torch.matmul()的区别 一.简介 torch.mul(a, b) 是矩阵a和b对应位相乘,a和b的维度必须相等,比如a的维度是(1, 2 ...

  9. 代码阅读 | torch.sort函数

    知识点https://blog.csdn.net/u012495579/article/details/106117511网友讲得非常清晰了. 代码如下: lengths = [17,17,19,23 ...

最新文章

  1. 【ZJOI2008】树的统计(树链剖分)
  2. EIGRP Metric计算
  3. [云炬创业基础笔记]第九章企业的法律形态测试3
  4. 【clickhouse】clickhouse 表引擎 之 VersionedCollapsingMergeTree
  5. CSS中调用JS函数和变量
  6. ip冲突 scan windows_如何检测IP有冲突 - 卡饭网
  7. python和java哪个好-python和java哪个更强大?
  8. PHP连接mysql8.0出错“SQLSTATE[HY000] [2054] The server requested authentication method unknow........
  9. linux下绿联USB转网卡驱动安装
  10. kettle抽取数据
  11. c语言小兔子原来有1个萝卜,小兔子和小狐狸的100个睡前晚安小故事
  12. Codevs P1066 引水入城 2010年NOIP全国联赛提高组
  13. 高等数学期末总复习DAY12.复合函数的链式求导、隐函数求导、
  14. 字典树学习 根据前缀词根建立字典树
  15. 2022-03-03 北京 计算机知识。字符编码,ppt
  16. 解决pytorch当中RuntimeError: expected scalar type Double but found Float的问题
  17. idea设置类注释和方法注释模板
  18. 软件工程毕业设计题目安卓Android移动端推荐
  19. opencv光线补偿_精准光线曝光补偿和包围曝光的运用
  20. Oracle - 基本入门

热门文章

  1. bootstrap支持ie8 让IE6 IE7 IE8 IE9 IE10 IE11支持Bootstrap的解决方法
  2. QT 5.7虚拟键盘(支持中文输入)Windows+Ubuntu
  3. [渝粤教育] 广东-国家-开放大学 21秋期末考试中国法律史10212k1
  4. 小波变换图像融合_【第11期 图像处理与仿真】 基于改进谱残差显著性图的红外与可见光图像融合...
  5. C#技巧 Lazy(延迟初始化)用法
  6. 软件测试中的批量交易测试
  7. OPPO折叠屏发布后,外媒把“矛头”对准三星,Find N和Fold 3哪个好?
  8. Android屏幕录制并传输,Android录制屏幕的实现方法
  9. 【转】你的模型真的陷入局部最优点了吗?
  10. KBP206-ASEMI整流桥KBP206