import torch
import numpy as np
t1=torch.tensor([1,2])
t2=torch.tensor([3,4])
t3=torch.tensor([5,6])
list_test=[t1,t2,t3] #a list of tensor
all_list=list_test
temp=[t.numpy() for t in all_list] # convert into a list of array
print("all_list",all_list)
print(all_list[0:2])
print(temp)
temp2=np.array(temp) #convert a list of array into a array
temp3=temp2[:,0]
print(temp3)
print(temp3.size)
print(temp3.shape)
temp4=torch.tensor(temp3) #将array重新转换为Tensor
#输出
all_list [tensor([1, 2]), tensor([3, 4]), tensor([5, 6])]
[tensor([1, 2]), tensor([3, 4])]
[array([1, 2], dtype=int64), array([3, 4], dtype=int64), array([5, 6], dtype=int64)]
[1 3 5]
3
(3,)