anantguptadbl:

import torch tmp=[torch.rand(2,4),torch.rand(2,4)] print(type(tmp)) print(type(tmp[0])) print(type(tmp[0][0])) # The full tmp print(tmp) # After a stack, you convert the list to a dimensions torch.stack(tmp)


@ptrblck  I was trying something with subclasses. Can you check whether it is in the right direction
class nestedTensor(torch.Tensor):
  def __new__(cls, x, *args, **kwargs): 
    print(super(nestedTensor,cls))
    return([super(torch.Tensor,cls).__new__(cls, y, *args, **kwargs) for y in x])
      
  def __init__(self, x): 
    print("Created nestedTensor")

tmp=nestedTensor([torch.rand(2,4),torch.rand(2,3),torch.rand(4,2)])
tmp