Convert a python list of python lists to pytorch tensor
What is the conventional way to convert python list of lists to PyTorch tensors?

a = [0,0]
b = [1,1]
c = [2]
c = [a, b, c]


I want c to be converted to a flattened Torch tensor as below:

torch([ 0, 0, 1, 1, 2])


You can flatten your list first in Python:

flat_list = [item for sublist in c for item in sublist]


And create your Tensor:

flattened_tensor = torch.FloatTensor(flat_list)

