**Problem :**

I am trying to convert my list into an array using Python,

But I got below error

**ValueError: only one element tensors can be converted to Python scalars.**

0 votes

It seems you have a list of tensors. For each tensor you can see its size(). If you want, you can convert a tensor to numpy array using numpy():

Returns a list of tensor shapes:

>> [t.size() for t in my_list_of_tensors]

Returns a list of numpy arrays:

>> [t.numpy() for t in my_list_of_tensors]

In terms of performance, it is always best to avoid casting of tensors into numpy arrays, If you only need to check the shape of a tensor, use size() function.