I have a torch tensor like this one:
A = torch.tensor([1,2,3,4,5,6]) there's in torch a simple way to generate a tensor like this?
[1, 1*2, 1*2*3, 1*2*3*4, 1*2*3*4*5, 1*2*3*4*5*6] Thanks a lot
1 Answer
You can use torch.cumprod:
import torch t = torch.tensor([1, 2, 3, 4, 5, 6]) torch.cumprod(t, dim=0) which outputs:
tensor([1, 2, 6, 24, 120, 720]) 1