day21 Tensor 操作3 入门 一起学 PyTorch吧,PyTorch从入门开始 每天都更新 超详细 参数 常用方法 简单案列 共同学习,共同进步 坚持

expand(*sizes) 返回 tensor 的一个新视图,单个维度扩大为更大的尺寸。tensor 也可以扩大为更高维,新增加的维度将附在前面。扩大 tensor 不需要分配新内存,只是仅仅新建一个tensor的视图,其中通过将stride设为0,一维将会扩展位更高维。任何一个一维的在不分配新内存的情况下可扩展任意的数值。index_add_(dim, index, tensor) –>Tensor 按参数 index 中的索引数确定的顺序,将参数 tensor 中的元素加到原来的 tensor 中。

eq(other) –>Tensor
请查看
torch.eq()
eq_(other) –>Tensor eq()

in-place
运算形式
equal(other) –>bool
请查看
torch.equal()
exp() –>Tensor
请查看
torch.exp()
exp_() –>Tensor exp()

in-place
运算形式
expand(*sizes)
返回
tensor
的一个新视图,单个维度扩大为更大的尺寸。tensor 也可以扩大为更高维,新增加的维度将附在前面。扩大
tensor
不需要分配新内存,只是仅仅新建一个tensor的视图,其中通过将stride设为0,一维将会扩展位更高维。任何一个一维的在不分配新内存的情况下可扩展任意的数值。
参数:
        –sizes(torch.Size or int…)-
需要扩展的大小
例子:
>>> x = torch.Tensor([[1], [2], [3]])
>>> x.size()
torch.Size([3, 1])
>>> x.expand(3, 4) 
1 1 
1 1 
2 2 2 2 
3 3 3 3 
[torch.FloatTensor of size 3x4]

tensor
扩展为参数
tensor
的大小。该操作等效于:
self.expand(tensor.size()) exponential_(lambd=1, *, generator=None) to
Tensor 将该tensor 用指数分布得到的元素填充:P
(
x
) =
λ
e
λ
x
fill_(value) –>Tensor将该tensor用指定的数值填充。
float()

tensor
投射为
float
类型
floor() –>Tensor
请查看
torch.floor()
floor_() –>Tensor floor()

in-place
运算形式
fmod(divisor) –>Tensor
请查看
torch.fmod()
fmod_(divisor) –>Tensor fmod()

in-place
运算形式
frac() –>Tensor
请查看
torch.frac()
frac_() –>Tensor frac()

in-place
运算形式
gather(dim, index) –>Tensor
请查看
torch.gather()
ge(other) –>Tensor
请查看
torch.ge()
ge_(other) –>Tensor ge()

in-place
运算形式
gels(A) –>Tensor
请查看
torch.gels()
geometric_(p, *, generator=None) –>Tensor
将该
tensor
用几何分布得到的元素填充:P
(
X
=
k
) =(
1
p
)
k
1
p
geqrf() -> (Tensor, Tensor)
请查看
torch.geqrf()
ger(vec2) –>Tensor
请查看
torch.ger()
gesv(A) –>Tensor, Tensor
请查看
torch.gesv()
gt(other) –>Tensor
请查看
torch.gt()
gt_(other) –>Tensor gt()

in-place
运算形式
half()

tensor
投射为半精度浮点类型
histc(bins=100, min=0, max=0) –>Tensor
请查看
torch.histc()
index(m) –>Tensor 用一个二进制的掩码或沿着一个给定的维度从
tensor
中选取元素。
tensor.index(m)

tensor[m]
完全相同。
m(int or Byte Tensor or slice)-
用来选取元素的维度或掩码
index_add_(dim, index, tensor) –>Tensor
按参数
index 中的索引数确定的顺序,将参数
tensor
中的元素加到原来的
tensor 中。参数 tensor 的尺寸必须严格地与原 tensor匹配,否则会发生错误。
参数:
        —
dim(int)-
索引
index
所指向的维度
        —
index(LongTensor)-
需要从
tensor
中选取的指数
        —tensor(Tensor)-含有相加元素的 tensor
例子:
>>> x = torch.Tensor([[1, 1, 1], [1, 1, 1], [1, 1, 1]])
>>> t = torch.Tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> index = torch.LongTensor([0, 2, 1])
>>> x.index_add_(0, index, t)
>>> x
2 3 4 
8 9 10
5 6 7 
[torch.FloatTensor of size 3x3]

版权声明:本文为博主Cchaofan原创文章,版权归属原作者,如果侵权,请联系我们删除!

原文链接:https://blog.csdn.net/Cchaofan/article/details/122564285

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2022年1月18日 下午5:24
下一篇 2022年1月18日 下午5:41

相关推荐