numpy转list
list_result=numpy.tolist()
list转numpy
a = np.array(b)
字符串转list
list_convert = a.split()
list转str
str_convert = ''.join(list)
str转list
test_list=list(test_str)
tensor转numpy
import torch
import numpy as np
np_data = np.arange(6).reshape((2, 3)) # The form of array
torch_data = torch.from_numpy(np_data) # Tensor print dtype=torch.int32
tensor2numpy = torch_data.numpy() # if torch data, then.numpy();if np_data, then torch.from_numpy(*)
print(
'\nnumpy:', np_data,
'\ntorch:', torch_data,
'\ntensor2numpy:', tensor2numpy
)