python 基础 -+- pandas 基础

torch.transpose 

import torch
a=torch.tensor([[[1,2,3],[4,5,6]],
                [[7,8,9],[10,11,12]]])
b=torch.transpose(a,1,2)
print("tensor_a",a)
print("tensor_b",b)
print("a的shape:",a.shape)
print("b的shape:",b.shape)

 

list转numpy 转tensor 

#创建 np.array的时候
a = np.array([2,3.2])
a.dtype = 'float32'
 
# numpy转 tensor
b=torch.from_numpy(a)# 数据类型不变

tensor 转化成list 

list(pred.cpu().numpy())

给列表的元素赋值 noehot向量


s = pd.Series(list('abca'))
print(pd.get_dummies(s))

os 读取目录下所有的文件

path="C:/Users/wang/Desktop/过程模型匹配/bpmn_zhouweiying/result/all_result/"
file_name_list = os.listdir(path)

 re.split 高级分割

line = 'abc[123]jk]l'
line_re_split = re.split('

猜你喜欢

转载自blog.csdn.net/qq_38735017/article/details/114885090
今日推荐