Hi Alpha!



 AlphaBetaGamma96:

tf.cumsum([a, b, c], exclusive=True)  => [0, a, a + b]  #exclusive cumsum

Let’s say I have a Tensor of [1,2,3]. However, if I wanted to take the “exclusive” cumsum which would be [0,1,3]?


The best I can think of is to use pytorch’s “standard” cumsum() and
use roll() to right-shift the result:
>>> t = torch.tensor ([1, 2, 3])
>>> res = t.cumsum (0).roll (1, 0)
>>> res[0] = 0
>>> print (res)
tensor([0, 1, 3])

Best.
K. Frank