PyTorch 对应点相乘、矩阵相乘实例
作者:Mr.Q 时间:2021-10-23 16:33:29
一,对应点相乘,x.mul(y) ,即点乘操作,点乘不求和操作,又可以叫作Hadamard product;点乘再求和,即为卷积
data = [[1,2], [3,4], [5, 6]]
tensor = torch.FloatTensor(data)
tensor
Out[27]:
tensor([[ 1., 2.],
[ 3., 4.],
[ 5., 6.]])
tensor.mul(tensor)
Out[28]:
tensor([[ 1., 4.],
[ 9., 16.],
[ 25., 36.]])
二,矩阵相乘,x.mm(y) , 矩阵大小需满足: (i, n)x(n, j)
tensor
Out[31]:
tensor([[ 1., 2.],
[ 3., 4.],
[ 5., 6.]])
tensor.mm(tensor.t()) # t()是转置
Out[30]:
tensor([[ 5., 11., 17.],
[ 11., 25., 39.],
[ 17., 39., 61.]])
来源:https://blog.csdn.net/jizhidexiaoming/article/details/82502724
标签:PyTorch,对应点,相乘,矩阵
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python文件操作的方法
2022-10-27 19:54:29
![](https://img.aspxhome.com/file/2023/8/107938_0s.jpg)
python+pandas+时间、日期以及时间序列处理方法
2021-09-08 04:46:32
SQL中Groupby和Having的使用方法
2008-12-29 13:54:00
Python Django view 两种return的实现方式
2022-05-03 16:07:04
python实现扫描日志关键字的示例
2023-10-20 15:44:02
![](https://img.aspxhome.com/file/2023/3/84053_0s.jpg)
3个JS控制图片滚动的效果
2007-10-23 13:40:00
![](https://img.aspxhome.com/file/UploadPic/200710/23/20071023145336612s.jpg)
彻底终结浏览器Cache页面的解决方案
2008-04-21 15:10:00
python中elasticsearch_dsl模块的使用方法
2022-03-23 07:57:31
![](https://img.aspxhome.com/file/2023/6/128586_0s.png)
Docker构建python Flask+ nginx+uwsgi容器
2023-07-25 06:36:43
![](https://img.aspxhome.com/file/2023/5/61685_0s.png)
django和vue互传图片并进行处理和展示
2021-04-24 20:39:16
浅谈Python数据处理csv的应用小结
2021-06-10 01:40:41
![](https://img.aspxhome.com/file/2023/6/75206_0s.png)
基于Opencv的图像卡通化实现代码
2023-07-10 06:58:55
![](https://img.aspxhome.com/file/2023/9/123779_0s.jpg)
PyQt5根据控件Id获取控件对象的方法
2023-02-13 15:22:50
python 基于opencv操作摄像头
2023-03-06 08:02:31
![](https://img.aspxhome.com/file/2023/6/121126_0s.png)
Python算法的时间复杂度和空间复杂度(实例解析)
2022-09-26 03:07:06
也谈access数据库的防下载保护
2007-08-28 13:01:00
关于Ajax在浏览器中产生前进后退的实现方法
2010-01-29 13:01:00
python rolling regression. 使用 Python 实现滚动回归操作
2021-01-11 09:38:07
利用Python自动生成PPT的示例详解
2021-10-16 18:25:08
![](https://img.aspxhome.com/file/2023/6/111856_0s.jpg)
元素层叠级别及z-index剖析
2008-07-22 12:03:00