import numpy as np
a = np.repeat(np.arange(5).reshape([1,-1]),10,axis=0)+10.0# np.arange(5)返回一个有终点和起点的固定步长的排列# np.repeat(item,num,axis)item重复num次
b = np.random.randint(5,size=a.shape)
c = np.argmin(a*b,axis=1)# a*b对应元素相乘。 np.argmin按照所在的维度取最小的那个维度的索引
b = np.zeros(a.shape)
b[np.arange(b.shape[0]),c]=1# one-hot编码,使用[]中的两个值作为索引进行变1操作print(b)
文章目录1、保存设置1、保存设置def zipdir(path, ziph): files = os.listdir(path) for file in files: if file.endswith(".py") or file.endswith("cfg"): ziph.write(os.path.join(path, file)) if file.endswith("cfg"): os.