class chainer.datasets.LabeledZippedImageDataset(zipfilename, labelfilename, dtype=None, label_dtype=<class 'numpy.int32'>)[source]

Dataset of zipped image and label pairs.

This dataset is zip version of LabeledImageDataset. It takes a zipfile like ZippedImageDataset. The label file shall contain lines like text file used in LabeledImageDataset, but a filename in each line of the label file shall match with a file in the zip archive.

  • zipfilename (str) – Path to a zipfile with images

  • labelfilename (str) – Path to a label file. i-th line shall contain a filename and an integer label that corresponds to the i-th sample. A filename in the label file shall match with a filename in the zip file given with zipfilename.

  • dtype – Data type of resulting image arrays. chainer.config.dtype is used by default (see Configuring Chainer).

  • label_dtype – Data type of the labels.



Returns an example or a sequence of examples.

It implements the standard Python indexing and one-dimensional integer array indexing. It uses the get_example() method by default, but it may be overridden by the implementation to, for example, improve the slicing performance.


index (int, slice, list or numpy.ndarray) – An index of an example or indexes of examples.


If index is int, returns an example created by get_example. If index is either slice or one-dimensional list or numpy.ndarray, returns a list of examples created by get_example.


>>> import numpy
>>> from chainer import dataset
>>> class SimpleDataset(dataset.DatasetMixin):
...     def __init__(self, values):
...         self.values = values
...     def __len__(self):
...         return len(self.values)
...     def get_example(self, i):
...         return self.values[i]
>>> ds = SimpleDataset([0, 1, 2, 3, 4, 5])
>>> ds[1]   # Access by int
>>> ds[1:3]  # Access by slice
[1, 2]
>>> ds[[4, 0]]  # Access by one-dimensional integer list
[4, 0]
>>> index = numpy.arange(3)
>>> ds[index]  # Access by one-dimensional integer numpy.ndarray
[0, 1, 2]

Returns the number of data points.


Returns the i-th example.

Implementations should override it. It should raise IndexError if the index is invalid.


i (int) – The index of the example.


The i-th example.


Return self==value.


Return self!=value.


Return self<value.


Return self<=value.


Return self>value.


Return self>=value.