Error relating to conversion from list to tensor in Pytorch
There is a variable 'tmp' (3 dimension).

tmp = [torch.tensor([1]),torch.tensor([2,3])]
type(tmp) -&gt; &lt;class 'list'&gt;
type(tmp[0]) -&gt; &lt;class 'torch.Tensor'&gt;
type(tmp[0][0]) -&gt; &lt;class 'torch.Tensor'&gt;



I want to convert 'tmp' into torch.Tensor type.
But, when I run this code below, an error occurs.

torch.Tensor(tmp)
&gt;&gt; ValueError: only one element tensors can be converted to Python scalars



How can I fix this?
torch.stack cannot be effective in this case because tensors in 'tmp' are not the same shape.

Use torch.stack - All tensors need to be of the same size in the list.

&gt;&gt;&gt; torch.stack(tmp)


Ex:

&gt;&gt;&gt; tmp = [torch.rand(2,2),torch.rand(2,2)]

&gt;&gt;&gt; tmp = torch.stack(tmp)
&gt;&gt;&gt; tmp
tensor([[[0.0212, 0.1864],
         [0.0070, 0.3381]],

        [[0.1607, 0.9568],
         [0.9093, 0.1835]]])
&gt;&gt;&gt; type(tmp)
&lt;class 'torch.Tensor'&gt;

