Create a single tensor from list of tensors

Hi!
I have mistaken list of tensor as a simple python list. (So I have also changed the title of question.)
The variable ‘data’ was actually a list of tensors with only one item. And I can’t create a tensor from a list of tensors using torch.Tensor() method. Hence the error.
I used the below method to turn the list of tensor into a single tensor :
X = torch.stack(data)
And it works now. Thanks! :slight_smile:

3 Likes