1.torch.cumsum(input, dim, *, dtype=None, out=None) → Tensor
返回维度 dim 中输入元素的累积和
>>> import torch
>>> a = torch.randn(10)
>>> a
tensor([-2.5726, 0.5631, -0.4157, -0.7383, -0.2587, 0.5975, -0.5162, -1.0037,
-0.5156, -0.3620])
>>> torch.cumsum(a,dim=0)
tensor([-2.5726, -2.0096, -2.4253, -3.1636, -3.4223, -2.8249, -3.3411, -4.3448,
-4.8604, -5.2224])
2.torch.sum(input, *, dtype=None) → Tensor
返回输入Tensor中的所有元素的总和。
>>> a = torch.randn(1, 3)
>>> a
tensor([[ 0.1133, -0.9567, 0.2958]])
>>> torch.sum(a)
tensor(-0.5475)