cumprod(exclusive=True) equivalences?

Hey,
torch.cumprod() does not have the “exclusive=True” flag as in tensorflow is that right?

Yes, there is no such a flag in pytorch. What does it do?

From the tensorflow documentation:

By default, this op performs an inclusive cumprod, which means that the first element of the input is identical to the first element of the output:

tf.cumprod([a, b, c]) ==> [a, a * b, a * b * c]

By setting the exclusive kwarg to True, an exclusive cumprod is performed instead:

tf.cumprod([a, b, c], exclusive=True) ==> [1, a, a * b]

I can try to just divide the result from cumprod() by the first element from each row, but it’s not numerically stable if the first element is close to 0

Yeah, there is no such option in PyTorch.
But you can do something like

res = torch.cumprod(torch.Tensor([1, a, b, c]), 0)
res = res[:-1]

Ok I can try that, thanks!

Hey,
another question, when I try to do cumprod() on a Variable, it says: Type Variable doesn’t implement stateless method cumprod, can you explain why is this method stateless (which means it does not track the computations happened in here I guess?)? Thanks a lot!

cumprod is not yet implemented in autograd, but there is a PR coming soon https://github.com/pytorch/pytorch/pull/1439

Ah ok, great, many thanks you guys, awesome framework:D