一.数据打包pickle
二.dict,tuple.ndarray的数据处理,
可以将numpy矩阵逐步转化为tensor的shape
import numpy as np # import math # make an example object to pickle some_obj = {'x':((4.0,5.0,6.0),(1.0,2.0,3.0)), 'y':((1.0,2.0,3.0),(4.0,5.0,6.0))}//在做/时,直接返回的float some_obj是dict,value是tuple print(some_obj['x']) values = some_obj.values() names = list(set(map(lambda x: x[0], some_obj.keys()))) x = [] for name in names: x.append(some_obj[name]) x = np.vstack(x)##<class 'numpy.ndarray'> shape(4, 3) y = x.copy()//数组赋值是浅拷贝,ndarry.copy()深拷贝 for i in range(0, 4, 1): if i%2==0: y[i,:] = x[i,:]+x[i+1,:]//y[i,:]表示一行 else: y[i,:] = x[i,:]-x[i-1,:] tensor = np.reshape(y,(2,2,3)) print(np.shape(y)) #want transform x to tensor shape[2,2,3] print(type(y)) print(tensor) print(np.shape(tensor))