def unpickle(file):
import pickle
with open(file, 'rb') as fo:
dict = pickle.load(fo, encoding='bytes')
return dict
dict1 = unpickle(data_dir1)
dict2 = unpickle(data_dir2)
dict3 = unpickle(data_dir3)
dict4 = unpickle(data_dir4)
dict5 = unpickle(data_dir5)
数据格式(来自CIFAR-10):
以这种方式加载的每个批处理文件都包含一个字典,其中包含以下元素:
data -- a 10000x3072 numpy array of uint8s. Each row of the array stores a 32x32 colour image. The first 1024 entries contain the red channel values, the next 1024 the green, and the final 1024 the blue. The image is stored in row-major order, so that the first 32 entries of the array are the red channel values of the first row of the image.
我的目标是将存储在字典中的所有numpy数组放在一起,作为一个大的numpy数组组(不覆盖)。你知道吗
np.concatenate((dict1, dict2, dict3, dict4, dict5), axis=0)
应该有用相关问题 更多 >
编程相关推荐