程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

2023-06(1)

Pytorch学习之torch----数学操作(三)

发布于2019-08-07 11:49     阅读(964)     评论(0)     点赞(1)     收藏(0)


1. torch.reciprocal(input, out=None) 

说明:返回一个新张量,包含输入input张量每个元素的倒数。

参数

  • input(Tensor) -- 输入张量
  • out(Tensor, 可选) -- 输出张量
>>> a = torch.randn(5)
>>> a
tensor([ 0.6535,  1.3616, -1.6167, -0.0142,  0.0186])
>>> torch.reciprocal(a)
tensor([  1.5303,   0.7345,  -0.6186, -70.6554,  53.8015])

2. torch.remainder(input, divisor, out=None)

说明:返回一个新张量,包含输入input张量每个元素的除法余数。除数与被除数可能同时包含整数或浮点数,余数与除数有相同的符号

参数

  • input(Tensor) -- 被除数
  • divisor(Tensor or float) -- 除数,一个数或者与除数相同大小的张量
  • out(Tensor,可选) -- 输出张量
>>> torch.remainder(torch.Tensor([-3, -2, -1, 1, 2, 3]), 2)
tensor([1., 0., 1., 1., 0., 1.])

3. torch.round(input, out=None)

说明:返回一个新张量,将输入input张量每个元素舍入到最近的整数

参数

  • input(Tensor) -- 输入张量
  • out(Tensor,可选) -- 输出张量
>>> a = torch.randn(4)
>>> torch.round(a)
tensor([-0.,  1., -1.,  0.])

4. torch.rsqrt(input, out=None)

说明:返回一个新张量,包含输入input张量每个元素的平方根倒数。

参数

  • input(Tensor) -- 输入张量
  • out(Tensor,可选0 -- 输出张量
>>> a = torch.randn(4)
>>> a
tensor([ 0.0934,  0.2079, -0.4841, -3.2004])
>>> torch.rsqrt(a)
tensor([3.2716, 2.1930,    nan,    nan])

5. torch.sigmoid(input, out=None)

说明:返回一个新张量,包含输入input张量每个元素的sigmoid值

参数:

  • input(Tensor) -- 输入张量
  • out(Tensor,可选) -- 输出张量
>>> a = torch.randn(4)
>>> a
tensor([ 0.6220,  0.4341, -0.5248,  0.8342])
>>> torch.sigmoid(a)
tensor([0.6507, 0.6068, 0.3717, 0.6973])

6. torch.sign(input, out=None) 

说明:符号函数,返回一个新张量,包含输入input张量每个元素的正负

参数

  • input(Tensor) -- 输入张量
  • out(Tensor,可选) -- 输出张量
>>> a = torch.randn(4)
>>> a
tensor([ 0.1224,  0.6647, -0.3843,  1.2878])
>>> torch.sign(a)
tensor([ 1.,  1., -1.,  1.])

7. torch.sin(input, out=None)

说明:返回一个新张量,包含输入input张量每个元素的正弦。

参数

  • input(Tensor) -- 输入张量
  • out(Tensor, 可选) -- 输出张量
>>> a = torch.randn(4)
>>> torch.sin(a)
tensor([-0.8258, -0.8077, -0.5048,  0.9997])

8. torch.sinh(input, out=None) 

说明:返回一个新张量,包含输入input张量每个元素的双曲正弦

参数

  • input(Tensor) -- 输入张量
  • out(Tensor,可选) -- 输出张量
>>> a = torch.randn(4)
>>> a
tensor([ 1.1792, -1.0052, -0.2577, -0.1537])
>>> torch.sinh(a)
tensor([ 1.4722, -1.1833, -0.2605, -0.1543])

9. torch.sqrt(input, out=None)

说明:返回一个新张量,包含输入input张量每个元素的平方根

参数

  • input(Tensor) -- 输入张量
  • out(Tensor, 可选) -- 输出张量
>>> a = torch.randn(4)
>>> a
tensor([ 0.3252, -0.8610, -1.1563, -0.2361])
>>> torch.sqrt(a)
tensor([0.5703,    nan,    nan,    nan])

10. torch.tan(input, out=None)

说明:返回一个新张量,包含输入input张量每个元素的正切。

参数

  • input(Tensor) -- 输入张量
  • out(Tensor, 可选) -- 输出张量
>>> a = torch.randn(4)
>>> a
tensor([-0.4005, -0.2229, -1.4596, -0.7481])
>>> torch.tan(a)
tensor([-0.4233, -0.2267, -8.9521, -0.9280])

11. torch.tanh(input, out=None) 

说明:返回一个新张量,包含输入input张量每个元素的双曲正切

参数

  • input(Tensor) -- 输入张量
  • out(Tensor,可选) -- 输出张量
>>> a = torch.randn(4)
>>> torch.tanh(a)
tensor([-0.2677,  0.7824,  0.0271, -0.0853])

12. torch.trunc(input, out=None)

说明:返回一个新张量,包含输入张量每个元素的截断值(标量x的截断值是最接近其的整数)

参数

  • input(Tensor) -- 输入张量
  • out(Tensor,可选) -- 输出张量
>>> a = torch.randn(4)
>>> a
tensor([-0.1385, -0.7681,  0.4294,  0.4270])
>>> torch.trunc(a)
tensor([-0., -0., 0., 0.])

 



所属网站分类: 技术文章 > 博客

作者:短发越来越短

链接:https://www.pythonheidong.com/blog/article/10481/153b2075421f5b64ca03/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

1 0
收藏该文
已收藏

评论内容:(最多支持255个字符)