def load_cifar10_dataset(shape=(-<NUM_LIT:1>, <NUM_LIT:32>, <NUM_LIT:32>, <NUM_LIT:3>), path='<STR_LIT:data>', plotable=False):
path = os.path.join(path, '<STR_LIT>')<EOL>logging.info("<STR_LIT>".format(path))<EOL>def unpickle(file):<EOL><INDENT>fp = open(file, '<STR_LIT:rb>')<EOL>if sys.version_info.major == <NUM_LIT:2>:<EOL><INDENT>data = pickle.load(fp)<EOL><DEDENT>elif sys.version_info.major == <NUM_LIT:3>:<EOL><INDENT>data = pickle.load(fp, encoding='<STR_LIT>')<EOL><DEDENT>fp.close()<EOL>return data<EOL><DEDENT>filename = '<STR_LIT>'<EOL>url = '<STR_LIT>'<EOL>maybe_download_and_extract(filename, path, url, extract=True)<EOL>X_train = None<EOL>y_train = []<EOL>for i in range(<NUM_LIT:1>, <NUM_LIT:6>):<EOL><INDENT>data_dic = unpickle(os.path.join(path, '<STR_LIT>', "<STR_LIT>".format(i)))<EOL>if i == <NUM_LIT:1>:<EOL><INDENT>X_train = data_dic['<STR_LIT:data>']<EOL><DEDENT>else:<EOL><INDENT>X_train = np.vstack((X_train, data_dic['<STR_LIT:data>']))<EOL><DEDENT>y_train += data_dic['<STR_LIT>']<EOL><DEDENT>test_data_dic = unpickle(os.path.join(path, '<STR_LIT>', "<STR_LIT>"))<EOL>X_test = test_data_dic['<STR_LIT:data>']<EOL>y_test = np.array(test_data_dic['<STR_LIT>'])<EOL>if shape == (-<NUM_LIT:1>, <NUM_LIT:3>, <NUM_LIT:32>, <NUM_LIT:32>):<EOL><INDENT>X_test = X_test.reshape(shape)<EOL>X_train = X_train.reshape(shape)<EOL><DEDENT>elif shape == (-<NUM_LIT:1>, <NUM_LIT:32>, <NUM_LIT:32>, <NUM_LIT:3>):<EOL><INDENT>X_test = X_test.reshape(shape, order='<STR_LIT:F>')<EOL>X_train = X_train.reshape(shape, order='<STR_LIT:F>')<EOL>X_test = np.transpose(X_test, (<NUM_LIT:0>, <NUM_LIT:2>, <NUM_LIT:1>, <NUM_LIT:3>))<EOL>X_train = np.transpose(X_train, (<NUM_LIT:0>, <NUM_LIT:2>, <NUM_LIT:1>, <NUM_LIT:3>))<EOL><DEDENT>else:<EOL><INDENT>X_test = X_test.reshape(shape)<EOL>X_train = X_train.reshape(shape)<EOL><DEDENT>y_train = np.array(y_train)<EOL>if plotable:<EOL><INDENT>logging.info('<STR_LIT>')<EOL>fig = plt.figure(<NUM_LIT:1>)<EOL>logging.info('<STR_LIT>' % X_train[<NUM_LIT:0>].shape)<EOL>plt.ion()  <EOL>count = <NUM_LIT:1><EOL>for _ in range(<NUM_LIT:10>):  <EOL><INDENT>for _ in range(<NUM_LIT:10>):  <EOL><INDENT>_ = fig.add_subplot(<NUM_LIT:10>, <NUM_LIT:10>, count)<EOL>if shape == (-<NUM_LIT:1>, <NUM_LIT:3>, <NUM_LIT:32>, <NUM_LIT:32>):<EOL><INDENT>plt.imshow(np.transpose(X_train[count - <NUM_LIT:1>], (<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:0>)), interpolation='<STR_LIT>')<EOL><DEDENT>elif shape == (-<NUM_LIT:1>, <NUM_LIT:32>, <NUM_LIT:32>, <NUM_LIT:3>):<EOL><INDENT>plt.imshow(X_train[count - <NUM_LIT:1>], interpolation='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>plt.gca().xaxis.set_major_locator(plt.NullLocator())  <EOL>plt.gca().yaxis.set_major_locator(plt.NullLocator())<EOL>count = count + <NUM_LIT:1><EOL><DEDENT><DEDENT>plt.draw()  <EOL>plt.pause(<NUM_LIT:3>)  <EOL>logging.info("<STR_LIT>" % X_train.shape)<EOL>logging.info("<STR_LIT>" % y_train.shape)<EOL>logging.info("<STR_LIT>" % X_test.shape)<EOL>logging.info("<STR_LIT>" % y_test.shape)<EOL><DEDENT>X_train = np.asarray(X_train, dtype=np.float32)<EOL>X_test = np.asarray(X_test, dtype=np.float32)<EOL>y_train = np.asarray(y_train, dtype=np.int32)<EOL>y_test = np.asarray(y_test, dtype=np.int32)<EOL>return X_train, y_train, X_test, y_test<EOL>
Load CIFAR-10 dataset.

    It consists of 60000 32x32 colour images in 10 classes, with
    6000 images per class. There are 50000 training images and 10000 test images.

    The dataset is divided into five training batches and one test batch, each with
    10000 images. The test batch contains exactly 1000 randomly-selected images from
    each class. The training batches contain the remaining images in random order,
    but some training batches may contain more images from one class than another.
    Between them, the training batches contain exactly 5000 images from each class.

    Parameters
    ----------
    shape : tupe
        The shape of digit images e.g. (-1, 3, 32, 32) and (-1, 32, 32, 3).
    path : str
        The path that the data is downloaded to, defaults is ``data/cifar10/``.
    plotable : boolean
        Whether to plot some image examples, False as default.

    Examples
    --------
    >>> X_train, y_train, X_test, y_test = tl.files.load_cifar10_dataset(shape=(-1, 32, 32, 3))

    References
    ----------
    - `CIFAR website <https://www.cs.toronto.edu/~kriz/cifar.html>`__
    - `Data download link <https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz>`__
    - `<https://teratail.com/questions/28932>`__