We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
get_cifar100() does not work
`get_cifar100()` causes the following error.

```
>>> chainer.datasets.get_cifar100()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/chainer/datasets/cifar.py", line 84, in get_cifar100
    raw = _retrieve_cifar('cifar-100')
  File "/usr/local/lib/python2.7/dist-packages/chainer/datasets/cifar.py", line 145, in _retrieve_cifar
    return download.cache_or_load_file(path, creator, numpy.load)
  File "/usr/local/lib/python2.7/dist-packages/chainer/dataset/download.py", line 145, in cache_or_load_file
    content = creator(temp_path)
  File "/usr/local/lib/python2.7/dist-packages/chainer/datasets/cifar.py", line 127, in creator
    d = _pickle_load(archive.extractfile(file_name))
  File "/usr/lib/python2.7/tarfile.py", line 2143, in extractfile
    tarinfo = self.getmember(member)
  File "/usr/lib/python2.7/tarfile.py", line 1827, in getmember
    raise KeyError("filename %r not found" % name)
KeyError: "filename 'cifar-100-batches-py/data_batch_1' not found"
```

cifar-100's directory structure seems to be different from cifar-10's.

```
$ tar xvzf cifar-100-python.tar.gz 
cifar-100-python/
cifar-100-python/file.txt~
cifar-100-python/train
cifar-100-python/test
cifar-100-python/meta

$ tar xvzf cifar-10-python.tar.gz 
cifar-10-batches-py/
cifar-10-batches-py/data_batch_4
cifar-10-batches-py/readme.html
cifar-10-batches-py/test_batch
cifar-10-batches-py/data_batch_3
cifar-10-batches-py/batches.meta
cifar-10-batches-py/data_batch_2
cifar-10-batches-py/data_batch_5
cifar-10-batches-py/data_batch_1
```

They should not be retrieved with the same logic.
https://github.com/pfnet/chainer/blob/master/chainer/datasets/cifar.py#L126


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `chainer/datasets/cifar.py`
Content:
```
1 import os
2 import sys
3 import tarfile
4 
5 import numpy
6 import six.moves.cPickle as pickle
7 
8 from chainer.dataset import download
9 from chainer.datasets import tuple_dataset
10 
11 
12 def get_cifar10(withlabel=True, ndim=3, scale=1.):
13     """Gets the CIFAR-10 dataset.
14 
15     `CIFAR-10 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ is a set of small
16     natural images. Each example is an RGB color image of size 32x32,
17     classified into 10 groups. In the original images, each component of pixels
18     is represented by one-byte unsigned integer. This function scales the
19     components to floating point values in the interval ``[0, scale]``.
20 
21     This function returns the training set and the test set of the official
22     CIFAR-10 dataset. If ``withlabel`` is ``True``, each dataset consists of
23     tuples of images and labels, otherwise it only consists of images.
24 
25     Args:
26         withlabel (bool): If ``True``, it returns datasets with labels. In this
27             case, each example is a tuple of an image and a label. Otherwise,
28             the datasets only contain images.
29         ndim (int): Number of dimensions of each image. The shape of each image
30             is determined depending on ndim as follows:
31 
32             - ``ndim == 1``: the shape is ``(3072,)``
33             - ``ndim == 3``: the shape is ``(3, 32, 32)``
34 
35         scale (float): Pixel value scale. If it is 1 (default), pixels are
36             scaled to the interval ``[0, 1]``.
37 
38     Returns:
39         A tuple of two datasets. If ``withlabel`` is ``True``, both datasets
40         are :class:`~chainer.datasets.TupleDataset` instances. Otherwise, both
41         datasets are arrays of images.
42 
43     """
44     raw = _retrieve_cifar('cifar-10')
45     train = _preprocess_cifar(raw['train_x'], raw['train_y'],
46                               withlabel, ndim, scale)
47     test = _preprocess_cifar(raw['test_x'], raw['test_y'],
48                              withlabel, ndim, scale)
49     return train, test
50 
51 
52 def get_cifar100(withlabel=True, ndim=3, scale=1.):
53     """Gets the CIFAR-100 dataset.
54 
55     `CIFAR-100 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ is a set of
56     small natural images. Each example is an RGB color image of size 32x32,
57     classified into 100 groups. In the original images, each component
58     pixels is represented by one-byte unsigned integer. This function scales
59     the components to floating point values in the interval ``[0, scale]``.
60 
61     This function returns the training set and the test set of the official
62     CIFAR-100 dataset. If ``withlabel`` is ``True``, each dataset consists of
63     tuples of images and labels, otherwise it only consists of images.
64 
65     Args:
66         withlabel (bool): If ``True``, it returns datasets with labels. In this
67             case, each example is a tuple of an image and a label. Otherwise,
68             the datasets only contain images.
69         ndim (int): Number of dimensions of each image. The shape of each image
70             is determined depending on ndim as follows:
71 
72             - ``ndim == 1``: the shape is ``(3072,)``
73             - ``ndim == 3``: the shape is ``(3, 32, 32)``
74 
75         scale (float): Pixel value scale. If it is 1 (default), pixels are
76             scaled to the interval ``[0, 1]``.
77 
78     Returns:
79         A tuple of two datasets. If ``withlabel`` is ``True``, both
80         are :class:`~chainer.datasets.TupleDataset` instances. Otherwise, both
81         datasets are arrays of images.
82 
83     """
84     raw = _retrieve_cifar('cifar-100')
85     train = _preprocess_cifar(raw['train_x'], raw['train_y'],
86                               withlabel, ndim, scale)
87     test = _preprocess_cifar(raw['test_x'], raw['test_y'],
88                              withlabel, ndim, scale)
89     return train, test
90 
91 
92 def _preprocess_cifar(images, labels, withlabel, ndim, scale):
93     if ndim == 1:
94         images = images.reshape(-1, 3072)
95     elif ndim == 3:
96         images = images.reshape(-1, 3, 32, 32)
97     else:
98         raise ValueError('invalid ndim for CIFAR dataset')
99     images = images.astype(numpy.float32)
100     images *= scale / 255.
101 
102     if withlabel:
103         labels = labels.astype(numpy.int32)
104         return tuple_dataset.TupleDataset(images, labels)
105     else:
106         return images
107 
108 
109 def _retrieve_cifar(name):
110     root = download.get_dataset_directory('pfnet/chainer/cifar')
111     path = os.path.join(root, '{}.npz'.format(name))
112     url = 'https://www.cs.toronto.edu/~kriz/{}-python.tar.gz'.format(name)
113 
114     def creator(path):
115         archive_path = download.cached_download(url)
116 
117         train_x = numpy.empty((5, 10000, 3072), dtype=numpy.uint8)
118         train_y = numpy.empty((5, 10000), dtype=numpy.uint8)
119         test_y = numpy.empty(10000, dtype=numpy.uint8)
120 
121         dir_name = '{}-batches-py'.format(name)
122 
123         with tarfile.open(archive_path, 'r:gz') as archive:
124             # training set
125             for i in range(5):
126                 file_name = '{}/data_batch_{}'.format(dir_name, i + 1)
127                 d = _pickle_load(archive.extractfile(file_name))
128                 train_x[i] = d['data']
129                 train_y[i] = d['labels']
130 
131             # test set
132             file_name = '{}/test_batch'.format(dir_name)
133             d = _pickle_load(archive.extractfile(file_name))
134             test_x = d['data']
135             test_y[...] = d['labels']  # copy to array
136 
137         train_x = train_x.reshape(50000, 3072)
138         train_y = train_y.reshape(50000)
139 
140         numpy.savez_compressed(path, train_x=train_x, train_y=train_y,
141                                test_x=test_x, test_y=test_y)
142         return {'train_x': train_x, 'train_y': train_y,
143                 'test_x': test_x, 'test_y': test_y}
144 
145     return download.cache_or_load_file(path, creator, numpy.load)
146 
147 
148 def _pickle_load(f):
149     if sys.version_info > (3, ):
150         # python3
151         return pickle.load(f, encoding='latin-1')
152     else:
153         # python2
154         return pickle.load(f)
155
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/chainer/datasets/cifar.py b/chainer/datasets/cifar.py
--- a/chainer/datasets/cifar.py
+++ b/chainer/datasets/cifar.py
@@ -81,7 +81,7 @@
         datasets are arrays of images.
 
     """
-    raw = _retrieve_cifar('cifar-100')
+    raw = _retrieve_cifar_100()
     train = _preprocess_cifar(raw['train_x'], raw['train_y'],
                               withlabel, ndim, scale)
     test = _preprocess_cifar(raw['test_x'], raw['test_y'],
@@ -106,6 +106,32 @@
         return images
 
 
+def _retrieve_cifar_100():
+    root = download.get_dataset_directory('pfnet/chainer/cifar')
+    path = os.path.join(root, 'cifar-100.npz')
+    url = 'https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz'
+
+    def creator(path):
+
+        def load(archive, file_name):
+            d = _pickle_load(archive.extractfile(file_name))
+            x = d['data'].reshape((-1, 3072))
+            y = numpy.array(d['fine_labels'], dtype=numpy.uint8)
+            return x, y
+
+        archive_path = download.cached_download(url)
+        with tarfile.open(archive_path, 'r:gz') as archive:
+            train_x, train_y = load(archive, 'cifar-100-python/train')
+            test_x, test_y = load(archive, 'cifar-100-python/test')
+
+        numpy.savez_compressed(path, train_x=train_x, train_y=train_y,
+                               test_x=test_x, test_y=test_y)
+        return {'train_x': train_x, 'train_y': train_y,
+                'test_x': test_x, 'test_y': test_y}
+
+    return download.cache_or_load_file(path, creator, numpy.load)
+
+
 def _retrieve_cifar(name):
     root = download.get_dataset_directory('pfnet/chainer/cifar')
     path = os.path.join(root, '{}.npz'.format(name))

{"golden_diff": "diff --git a/chainer/datasets/cifar.py b/chainer/datasets/cifar.py\n--- a/chainer/datasets/cifar.py\n+++ b/chainer/datasets/cifar.py\n@@ -81,7 +81,7 @@\n         datasets are arrays of images.\n \n     \"\"\"\n-    raw = _retrieve_cifar('cifar-100')\n+    raw = _retrieve_cifar_100()\n     train = _preprocess_cifar(raw['train_x'], raw['train_y'],\n                               withlabel, ndim, scale)\n     test = _preprocess_cifar(raw['test_x'], raw['test_y'],\n@@ -106,6 +106,32 @@\n         return images\n \n \n+def _retrieve_cifar_100():\n+    root = download.get_dataset_directory('pfnet/chainer/cifar')\n+    path = os.path.join(root, 'cifar-100.npz')\n+    url = 'https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz'\n+\n+    def creator(path):\n+\n+        def load(archive, file_name):\n+            d = _pickle_load(archive.extractfile(file_name))\n+            x = d['data'].reshape((-1, 3072))\n+            y = numpy.array(d['fine_labels'], dtype=numpy.uint8)\n+            return x, y\n+\n+        archive_path = download.cached_download(url)\n+        with tarfile.open(archive_path, 'r:gz') as archive:\n+            train_x, train_y = load(archive, 'cifar-100-python/train')\n+            test_x, test_y = load(archive, 'cifar-100-python/test')\n+\n+        numpy.savez_compressed(path, train_x=train_x, train_y=train_y,\n+                               test_x=test_x, test_y=test_y)\n+        return {'train_x': train_x, 'train_y': train_y,\n+                'test_x': test_x, 'test_y': test_y}\n+\n+    return download.cache_or_load_file(path, creator, numpy.load)\n+\n+\n def _retrieve_cifar(name):\n     root = download.get_dataset_directory('pfnet/chainer/cifar')\n     path = os.path.join(root, '{}.npz'.format(name))\n", "issue": "get_cifar100() does not work\n`get_cifar100()` causes the following error.\n\n```\n>>> chainer.datasets.get_cifar100()\nTraceback (most recent call last):\n  File \"<stdin>\", line 1, in <module>\n  File \"/usr/local/lib/python2.7/dist-packages/chainer/datasets/cifar.py\", line 84, in get_cifar100\n    raw = _retrieve_cifar('cifar-100')\n  File \"/usr/local/lib/python2.7/dist-packages/chainer/datasets/cifar.py\", line 145, in _retrieve_cifar\n    return download.cache_or_load_file(path, creator, numpy.load)\n  File \"/usr/local/lib/python2.7/dist-packages/chainer/dataset/download.py\", line 145, in cache_or_load_file\n    content = creator(temp_path)\n  File \"/usr/local/lib/python2.7/dist-packages/chainer/datasets/cifar.py\", line 127, in creator\n    d = _pickle_load(archive.extractfile(file_name))\n  File \"/usr/lib/python2.7/tarfile.py\", line 2143, in extractfile\n    tarinfo = self.getmember(member)\n  File \"/usr/lib/python2.7/tarfile.py\", line 1827, in getmember\n    raise KeyError(\"filename %r not found\" % name)\nKeyError: \"filename 'cifar-100-batches-py/data_batch_1' not found\"\n```\n\ncifar-100's directory structure seems to be different from cifar-10's.\n\n```\n$ tar xvzf cifar-100-python.tar.gz \ncifar-100-python/\ncifar-100-python/file.txt~\ncifar-100-python/train\ncifar-100-python/test\ncifar-100-python/meta\n\n$ tar xvzf cifar-10-python.tar.gz \ncifar-10-batches-py/\ncifar-10-batches-py/data_batch_4\ncifar-10-batches-py/readme.html\ncifar-10-batches-py/test_batch\ncifar-10-batches-py/data_batch_3\ncifar-10-batches-py/batches.meta\ncifar-10-batches-py/data_batch_2\ncifar-10-batches-py/data_batch_5\ncifar-10-batches-py/data_batch_1\n```\n\nThey should not be retrieved with the same logic.\nhttps://github.com/pfnet/chainer/blob/master/chainer/datasets/cifar.py#L126\n\n", "before_files": [{"content": "import os\nimport sys\nimport tarfile\n\nimport numpy\nimport six.moves.cPickle as pickle\n\nfrom chainer.dataset import download\nfrom chainer.datasets import tuple_dataset\n\n\ndef get_cifar10(withlabel=True, ndim=3, scale=1.):\n    \"\"\"Gets the CIFAR-10 dataset.\n\n    `CIFAR-10 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ is a set of small\n    natural images. Each example is an RGB color image of size 32x32,\n    classified into 10 groups. In the original images, each component of pixels\n    is represented by one-byte unsigned integer. This function scales the\n    components to floating point values in the interval ``[0, scale]``.\n\n    This function returns the training set and the test set of the official\n    CIFAR-10 dataset. If ``withlabel`` is ``True``, each dataset consists of\n    tuples of images and labels, otherwise it only consists of images.\n\n    Args:\n        withlabel (bool): If ``True``, it returns datasets with labels. In this\n            case, each example is a tuple of an image and a label. Otherwise,\n            the datasets only contain images.\n        ndim (int): Number of dimensions of each image. The shape of each image\n            is determined depending on ndim as follows:\n\n            - ``ndim == 1``: the shape is ``(3072,)``\n            - ``ndim == 3``: the shape is ``(3, 32, 32)``\n\n        scale (float): Pixel value scale. If it is 1 (default), pixels are\n            scaled to the interval ``[0, 1]``.\n\n    Returns:\n        A tuple of two datasets. If ``withlabel`` is ``True``, both datasets\n        are :class:`~chainer.datasets.TupleDataset` instances. Otherwise, both\n        datasets are arrays of images.\n\n    \"\"\"\n    raw = _retrieve_cifar('cifar-10')\n    train = _preprocess_cifar(raw['train_x'], raw['train_y'],\n                              withlabel, ndim, scale)\n    test = _preprocess_cifar(raw['test_x'], raw['test_y'],\n                             withlabel, ndim, scale)\n    return train, test\n\n\ndef get_cifar100(withlabel=True, ndim=3, scale=1.):\n    \"\"\"Gets the CIFAR-100 dataset.\n\n    `CIFAR-100 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ is a set of\n    small natural images. Each example is an RGB color image of size 32x32,\n    classified into 100 groups. In the original images, each component\n    pixels is represented by one-byte unsigned integer. This function scales\n    the components to floating point values in the interval ``[0, scale]``.\n\n    This function returns the training set and the test set of the official\n    CIFAR-100 dataset. If ``withlabel`` is ``True``, each dataset consists of\n    tuples of images and labels, otherwise it only consists of images.\n\n    Args:\n        withlabel (bool): If ``True``, it returns datasets with labels. In this\n            case, each example is a tuple of an image and a label. Otherwise,\n            the datasets only contain images.\n        ndim (int): Number of dimensions of each image. The shape of each image\n            is determined depending on ndim as follows:\n\n            - ``ndim == 1``: the shape is ``(3072,)``\n            - ``ndim == 3``: the shape is ``(3, 32, 32)``\n\n        scale (float): Pixel value scale. If it is 1 (default), pixels are\n            scaled to the interval ``[0, 1]``.\n\n    Returns:\n        A tuple of two datasets. If ``withlabel`` is ``True``, both\n        are :class:`~chainer.datasets.TupleDataset` instances. Otherwise, both\n        datasets are arrays of images.\n\n    \"\"\"\n    raw = _retrieve_cifar('cifar-100')\n    train = _preprocess_cifar(raw['train_x'], raw['train_y'],\n                              withlabel, ndim, scale)\n    test = _preprocess_cifar(raw['test_x'], raw['test_y'],\n                             withlabel, ndim, scale)\n    return train, test\n\n\ndef _preprocess_cifar(images, labels, withlabel, ndim, scale):\n    if ndim == 1:\n        images = images.reshape(-1, 3072)\n    elif ndim == 3:\n        images = images.reshape(-1, 3, 32, 32)\n    else:\n        raise ValueError('invalid ndim for CIFAR dataset')\n    images = images.astype(numpy.float32)\n    images *= scale / 255.\n\n    if withlabel:\n        labels = labels.astype(numpy.int32)\n        return tuple_dataset.TupleDataset(images, labels)\n    else:\n        return images\n\n\ndef _retrieve_cifar(name):\n    root = download.get_dataset_directory('pfnet/chainer/cifar')\n    path = os.path.join(root, '{}.npz'.format(name))\n    url = 'https://www.cs.toronto.edu/~kriz/{}-python.tar.gz'.format(name)\n\n    def creator(path):\n        archive_path = download.cached_download(url)\n\n        train_x = numpy.empty((5, 10000, 3072), dtype=numpy.uint8)\n        train_y = numpy.empty((5, 10000), dtype=numpy.uint8)\n        test_y = numpy.empty(10000, dtype=numpy.uint8)\n\n        dir_name = '{}-batches-py'.format(name)\n\n        with tarfile.open(archive_path, 'r:gz') as archive:\n            # training set\n            for i in range(5):\n                file_name = '{}/data_batch_{}'.format(dir_name, i + 1)\n                d = _pickle_load(archive.extractfile(file_name))\n                train_x[i] = d['data']\n                train_y[i] = d['labels']\n\n            # test set\n            file_name = '{}/test_batch'.format(dir_name)\n            d = _pickle_load(archive.extractfile(file_name))\n            test_x = d['data']\n            test_y[...] = d['labels']  # copy to array\n\n        train_x = train_x.reshape(50000, 3072)\n        train_y = train_y.reshape(50000)\n\n        numpy.savez_compressed(path, train_x=train_x, train_y=train_y,\n                               test_x=test_x, test_y=test_y)\n        return {'train_x': train_x, 'train_y': train_y,\n                'test_x': test_x, 'test_y': test_y}\n\n    return download.cache_or_load_file(path, creator, numpy.load)\n\n\ndef _pickle_load(f):\n    if sys.version_info > (3, ):\n        # python3\n        return pickle.load(f, encoding='latin-1')\n    else:\n        # python2\n        return pickle.load(f)\n", "path": "chainer/datasets/cifar.py"}], "after_files": [{"content": "import os\nimport sys\nimport tarfile\n\nimport numpy\nimport six.moves.cPickle as pickle\n\nfrom chainer.dataset import download\nfrom chainer.datasets import tuple_dataset\n\n\ndef get_cifar10(withlabel=True, ndim=3, scale=1.):\n    \"\"\"Gets the CIFAR-10 dataset.\n\n    `CIFAR-10 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ is a set of small\n    natural images. Each example is an RGB color image of size 32x32,\n    classified into 10 groups. In the original images, each component of pixels\n    is represented by one-byte unsigned integer. This function scales the\n    components to floating point values in the interval ``[0, scale]``.\n\n    This function returns the training set and the test set of the official\n    CIFAR-10 dataset. If ``withlabel`` is ``True``, each dataset consists of\n    tuples of images and labels, otherwise it only consists of images.\n\n    Args:\n        withlabel (bool): If ``True``, it returns datasets with labels. In this\n            case, each example is a tuple of an image and a label. Otherwise,\n            the datasets only contain images.\n        ndim (int): Number of dimensions of each image. The shape of each image\n            is determined depending on ndim as follows:\n\n            - ``ndim == 1``: the shape is ``(3072,)``\n            - ``ndim == 3``: the shape is ``(3, 32, 32)``\n\n        scale (float): Pixel value scale. If it is 1 (default), pixels are\n            scaled to the interval ``[0, 1]``.\n\n    Returns:\n        A tuple of two datasets. If ``withlabel`` is ``True``, both datasets\n        are :class:`~chainer.datasets.TupleDataset` instances. Otherwise, both\n        datasets are arrays of images.\n\n    \"\"\"\n    raw = _retrieve_cifar('cifar-10')\n    train = _preprocess_cifar(raw['train_x'], raw['train_y'],\n                              withlabel, ndim, scale)\n    test = _preprocess_cifar(raw['test_x'], raw['test_y'],\n                             withlabel, ndim, scale)\n    return train, test\n\n\ndef get_cifar100(withlabel=True, ndim=3, scale=1.):\n    \"\"\"Gets the CIFAR-100 dataset.\n\n    `CIFAR-100 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ is a set of\n    small natural images. Each example is an RGB color image of size 32x32,\n    classified into 100 groups. In the original images, each component\n    pixels is represented by one-byte unsigned integer. This function scales\n    the components to floating point values in the interval ``[0, scale]``.\n\n    This function returns the training set and the test set of the official\n    CIFAR-100 dataset. If ``withlabel`` is ``True``, each dataset consists of\n    tuples of images and labels, otherwise it only consists of images.\n\n    Args:\n        withlabel (bool): If ``True``, it returns datasets with labels. In this\n            case, each example is a tuple of an image and a label. Otherwise,\n            the datasets only contain images.\n        ndim (int): Number of dimensions of each image. The shape of each image\n            is determined depending on ndim as follows:\n\n            - ``ndim == 1``: the shape is ``(3072,)``\n            - ``ndim == 3``: the shape is ``(3, 32, 32)``\n\n        scale (float): Pixel value scale. If it is 1 (default), pixels are\n            scaled to the interval ``[0, 1]``.\n\n    Returns:\n        A tuple of two datasets. If ``withlabel`` is ``True``, both\n        are :class:`~chainer.datasets.TupleDataset` instances. Otherwise, both\n        datasets are arrays of images.\n\n    \"\"\"\n    raw = _retrieve_cifar_100()\n    train = _preprocess_cifar(raw['train_x'], raw['train_y'],\n                              withlabel, ndim, scale)\n    test = _preprocess_cifar(raw['test_x'], raw['test_y'],\n                             withlabel, ndim, scale)\n    return train, test\n\n\ndef _preprocess_cifar(images, labels, withlabel, ndim, scale):\n    if ndim == 1:\n        images = images.reshape(-1, 3072)\n    elif ndim == 3:\n        images = images.reshape(-1, 3, 32, 32)\n    else:\n        raise ValueError('invalid ndim for CIFAR dataset')\n    images = images.astype(numpy.float32)\n    images *= scale / 255.\n\n    if withlabel:\n        labels = labels.astype(numpy.int32)\n        return tuple_dataset.TupleDataset(images, labels)\n    else:\n        return images\n\n\ndef _retrieve_cifar_100():\n    root = download.get_dataset_directory('pfnet/chainer/cifar')\n    path = os.path.join(root, 'cifar-100.npz')\n    url = 'https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz'\n\n    def creator(path):\n\n        def load(archive, file_name):\n            d = _pickle_load(archive.extractfile(file_name))\n            x = d['data'].reshape((-1, 3072))\n            y = numpy.array(d['fine_labels'], dtype=numpy.uint8)\n            return x, y\n\n        archive_path = download.cached_download(url)\n        with tarfile.open(archive_path, 'r:gz') as archive:\n            train_x, train_y = load(archive, 'cifar-100-python/train')\n            test_x, test_y = load(archive, 'cifar-100-python/test')\n\n        numpy.savez_compressed(path, train_x=train_x, train_y=train_y,\n                               test_x=test_x, test_y=test_y)\n        return {'train_x': train_x, 'train_y': train_y,\n                'test_x': test_x, 'test_y': test_y}\n\n    return download.cache_or_load_file(path, creator, numpy.load)\n\n\ndef _retrieve_cifar(name):\n    root = download.get_dataset_directory('pfnet/chainer/cifar')\n    path = os.path.join(root, '{}.npz'.format(name))\n    url = 'https://www.cs.toronto.edu/~kriz/{}-python.tar.gz'.format(name)\n\n    def creator(path):\n        archive_path = download.cached_download(url)\n\n        train_x = numpy.empty((5, 10000, 3072), dtype=numpy.uint8)\n        train_y = numpy.empty((5, 10000), dtype=numpy.uint8)\n        test_y = numpy.empty(10000, dtype=numpy.uint8)\n\n        dir_name = '{}-batches-py'.format(name)\n\n        with tarfile.open(archive_path, 'r:gz') as archive:\n            # training set\n            for i in range(5):\n                file_name = '{}/data_batch_{}'.format(dir_name, i + 1)\n                d = _pickle_load(archive.extractfile(file_name))\n                train_x[i] = d['data']\n                train_y[i] = d['labels']\n\n            # test set\n            file_name = '{}/test_batch'.format(dir_name)\n            d = _pickle_load(archive.extractfile(file_name))\n            test_x = d['data']\n            test_y[...] = d['labels']  # copy to array\n\n        train_x = train_x.reshape(50000, 3072)\n        train_y = train_y.reshape(50000)\n\n        numpy.savez_compressed(path, train_x=train_x, train_y=train_y,\n                               test_x=test_x, test_y=test_y)\n        return {'train_x': train_x, 'train_y': train_y,\n                'test_x': test_x, 'test_y': test_y}\n\n    return download.cache_or_load_file(path, creator, numpy.load)\n\n\ndef _pickle_load(f):\n    if sys.version_info > (3, ):\n        # python3\n        return pickle.load(f, encoding='latin-1')\n    else:\n        # python2\n        return pickle.load(f)\n", "path": "chainer/datasets/cifar.py"}]}