python zip()函数
# print(len(data)) batch 个 tuple(torch.float(3,224,224), str)
# print(data[0][0].size()) [3,224,224]
# print(data[0][1].size()) [len]
images, captions = zip(*data)
# images = batch个[3,224,224] # images[0].size()) [3,224,224]# captions = batch 个str
1.解压
传入的data为batch个元祖,即batch个(images,captions)对儿。
images, captions = zip(*data)
zip(*data) = (batch个images,batch个captions)
2.压
data = zip(images,captions)