Having the following pickled data:
[array([[[148, 124, 115],
[150, 127, 116],
[154, 129, 121],
...,
[159, 142, 133],
[159, 142, 133],
[161, 145, 142]]]), array([1])]
I was able to retrieve the data and label, as follows:
data = batch[0]
labels = batch[1]
In which case, I had the following output when making a print for both data and label, separately:
[[[148 124 115]
[150 127 116]
[154 129 121]
...,
[159 142 133]
[159 142 133]
[161 145 142]]]
[1]
When my batch file now looks as follows as I added a new image, I didn't figure out how to read the 2nd image and its label. It seems I cannot understand how the pickled file is indexed here:
[array([[[148, 124, 115],
[150, 127, 116],
[154, 129, 121],
...,
[159, 142, 133],
[159, 142, 133],
[161, 145, 142]],
[[165, 136, 145],
[176, 137, 141],
[178, 138, 144],
...,
[199, 163, 171],
[202, 163, 167],
[200, 158, 163]]]), array([1, 1])]
How can I iterate through such pickled file? How is the file indexed? Especially that I would like to add more images along with their labels.
Thanks.
解决方案
The way your data is pickled, the two images end up in the same array and thus you have to index accordingly:
batch[0][0] #this will give the first image
batch[0][1] #this will give the second image
batch[1][0] #this will give the first label
batch[1][1] #this will give the second label