def load_cropped_svhn(path='<STR_LIT:data>', include_extra=True):
start_time = time.time()<EOL>path = os.path.join(path, '<STR_LIT>')<EOL>logging.info("<STR_LIT>".format(path, include_extra))<EOL>url = "<STR_LIT>"<EOL>np_file = os.path.join(path, "<STR_LIT>")<EOL>if file_exists(np_file) is False:<EOL><INDENT>filename = "<STR_LIT>"<EOL>filepath = maybe_download_and_extract(filename, path, url)<EOL>mat = sio.loadmat(filepath)<EOL>X_train = mat['<STR_LIT:X>'] / <NUM_LIT>  <EOL>X_train = np.transpose(X_train, (<NUM_LIT:3>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:2>))<EOL>y_train = np.squeeze(mat['<STR_LIT:y>'], axis=<NUM_LIT:1>)<EOL>y_train[y_train == <NUM_LIT:10>] = <NUM_LIT:0>  <EOL>np.savez(np_file, X=X_train, y=y_train)<EOL>del_file(filepath)<EOL><DEDENT>else:<EOL><INDENT>v = np.load(np_file)<EOL>X_train = v['<STR_LIT:X>']<EOL>y_train = v['<STR_LIT:y>']<EOL><DEDENT>logging.info("<STR_LIT>".format(len(y_train)))<EOL>np_file = os.path.join(path, "<STR_LIT>")<EOL>if file_exists(np_file) is False:<EOL><INDENT>filename = "<STR_LIT>"<EOL>filepath = maybe_download_and_extract(filename, path, url)<EOL>mat = sio.loadmat(filepath)<EOL>X_test = mat['<STR_LIT:X>'] / <NUM_LIT><EOL>X_test = np.transpose(X_test, (<NUM_LIT:3>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:2>))<EOL>y_test = np.squeeze(mat['<STR_LIT:y>'], axis=<NUM_LIT:1>)<EOL>y_test[y_test == <NUM_LIT:10>] = <NUM_LIT:0><EOL>np.savez(np_file, X=X_test, y=y_test)<EOL>del_file(filepath)<EOL><DEDENT>else:<EOL><INDENT>v = np.load(np_file)<EOL>X_test = v['<STR_LIT:X>']<EOL>y_test = v['<STR_LIT:y>']<EOL><DEDENT>logging.info("<STR_LIT>".format(len(y_test)))<EOL>if include_extra:<EOL><INDENT>logging.info("<STR_LIT>")<EOL>np_file = os.path.join(path, "<STR_LIT>")<EOL>if file_exists(np_file) is False:<EOL><INDENT>logging.info("<STR_LIT>")<EOL>filename = "<STR_LIT>"<EOL>filepath = maybe_download_and_extract(filename, path, url)<EOL>mat = sio.loadmat(filepath)<EOL>X_extra = mat['<STR_LIT:X>'] / <NUM_LIT><EOL>X_extra = np.transpose(X_extra, (<NUM_LIT:3>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:2>))<EOL>y_extra = np.squeeze(mat['<STR_LIT:y>'], axis=<NUM_LIT:1>)<EOL>y_extra[y_extra == <NUM_LIT:10>] = <NUM_LIT:0><EOL>np.savez(np_file, X=X_extra, y=y_extra)<EOL>del_file(filepath)<EOL><DEDENT>else:<EOL><INDENT>v = np.load(np_file)<EOL>X_extra = v['<STR_LIT:X>']<EOL>y_extra = v['<STR_LIT:y>']<EOL><DEDENT>logging.info("<STR_LIT>".format(len(y_extra), len(y_train)))<EOL>t = time.time()<EOL>X_train = np.concatenate((X_train, X_extra), <NUM_LIT:0>)<EOL>y_train = np.concatenate((y_train, y_extra), <NUM_LIT:0>)<EOL>logging.info("<STR_LIT>".format(len(y_extra), len(y_train), time.time() - t))<EOL><DEDENT>else:<EOL><INDENT>logging.info("<STR_LIT>")<EOL><DEDENT>logging.info("<STR_LIT>" % (str(X_train.shape[<NUM_LIT:1>:<NUM_LIT:4>]), len(y_train), len(y_test)))<EOL>logging.info("<STR_LIT>".format(int(time.time() - start_time)))<EOL>return X_train, y_train, X_test, y_test<EOL>
Load Cropped SVHN.

    The Cropped Street View House Numbers (SVHN) Dataset contains 32x32x3 RGB images.
    Digit '1' has label 1, '9' has label 9 and '0' has label 0 (the original dataset uses 10 to represent '0'), see `ufldl website <http://ufldl.stanford.edu/housenumbers/>`__.

    Parameters
    ----------
    path : str
        The path that the data is downloaded to.
    include_extra : boolean
        If True (default), add extra images to the training set.

    Returns
    -------
    X_train, y_train, X_test, y_test: tuple
        Return splitted training/test set respectively.

    Examples
    ---------
    >>> X_train, y_train, X_test, y_test = tl.files.load_cropped_svhn(include_extra=False)
    >>> tl.vis.save_images(X_train[0:100], [10, 10], 'svhn.png')