I have a tensor of 4 dimensions let#s call them N,T,V,C, now I would like to have a tensor of dimension N,T,C^V, or better N,T,C,C,…,C for V times, where the elements are the outher products of the V,C matrix rows for each N,T. I am in a nn.module enviroment with parameters associated so I have to use torch functions and all needed to then be able to do the gradient of the parameters.
Thanks
I can do it like this
X = torch.rand((1000,,2,10))
Y = X.view(-1, X.shape[2], X.shape[3])
Z = []
for i in Y:
comb = [j for j in i]
Z.append(torch.sum(torch.tensor(list(itertools.product(*comb))),dim=1))
where before stacking I sum the elements of the vector of combinations, which is a plus but not needed. it works but not in the layer enviroment with parameters.