码迷,mamicode.com
首页 > 其他好文 > 详细

pytorch中Math operation操作:torch.ger()

时间:2018-09-27 19:47:56      阅读:361      评论:0      收藏:0      [点我收藏+]

标签:class   field   pytorch   math   doc   ret   range   ref   body   

torch.ger(vec1vec2out=None) → Tensor

Outer product of vec1 and vec2. If vec1 is a vector of size nn and vec2 is a vector of size mm, then out must be a matrix of size (n×m).

Parameters:
  • vec1 (Tensor) – 1-D input vector
  • vec2 (Tensor) – 1-D input vector
  • out (Tensoroptional) – optional output matrix

Example:

>>> v1 = torch.arange(1., 5.)
>>> v2 = torch.arange(1., 4.)
>>> torch.ger(v1, v2)
tensor([[  1.,   2.,   3.],
        [  2.,   4.,   6.],
        [  3.,   6.,   9.],
        [  4.,   8.,  12.]])
从例子以及描述可知,这是一个向量间外积的操作。

pytorch中Math operation操作:torch.ger()

标签:class   field   pytorch   math   doc   ret   range   ref   body   

原文地址:https://www.cnblogs.com/qinduanyinghua/p/9715080.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!