在不覆盖的情况下连接5个未勾选的字典(数据来自CIFAR10)

2024-04-29 09:33:25 发布

您现在位置:Python中文网/ 问答频道 /正文

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数组组(不覆盖)。你知道吗


Tags: oftheimagenumpydata字典arraypickle