ValueError: only one element tensors can be converted to Python scalars when using torch.Tensor on list of tensors
I have a list of tensors:
object_ids = [tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.])]

Intuitively, it seems like I should be able to create a new tensor from this:
torch.as_tensor(object_ids, dtype=torch.float32)

But this does NOT work. Apparently, torch.as_tensor and torch.Tensor can only turn lists of scalars into new tensors. it cannot turn a list of d-dim tensors into a d+1 dim tensor.

You can use torch.stack.
In your example:
&gt;&gt;&gt; object_ids = [tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.]), tensor([2., 3.])]
&gt;&gt;&gt; torch.stack(object_ids)
tensor([[2., 3.],
        [2., 3.],
        [2., 3.],
        [2., 3.],
        [2., 3.],
        [2., 3.],
        [2., 3.],
        [2., 3.],
        [2., 3.],
        [2., 3.]])

