Converting list of tensors to a tesnor module

i have tensors of size [336,261] generated in for loop for 10 iterations, i want them to be stored as out=[10,336,261]. what is the possible way to do this?

Right now i am storing it in list but when i have been unable to convert the list in a tensor module. any suggestions or help?

Hello
you could use torch.stack
If tensor_list is the list of the tensors you obtain after the loop then -

desired_tensor = torch.stack(tensor_list, dim=0)

thank you. it works like charm.