def _download(extra=False, normalize=True):

    def norm(x):
        x = x.swapaxes(2,3).swapaxes(1,2)
        x = x.reshape((-1, 3, 32 * 32))
        std = x.std(axis=(-1, 0))
        x[:, 0] /= std[0]
        x[:, 1] /= std[1]
        x[:, 2] /= std[2]
        x = x.reshape((-1, 3 * 32 * 32))
        return x

    train_x, train_t, test_x, test_t = load_svhn(os.path.join(env_paths.get_data_path("svhn"), ""),
                                                 normalize=False,
                                                 dequantify=True,
                                                 extra=extra)

    if normalize:
        train_x = norm(train_x)
        test_x = norm(test_x)

    train_t = np.array(train_t, dtype='float32').reshape(-1)
    test_t = np.array(test_t, dtype='float32').reshape(-1)

    # Dummy validation set. NOTE: still in training set.
    idx = np.random.randint(0, train_x.shape[0] - 1, 5000)
    valid_x = train_x[idx, :]
    valid_t = train_t[idx]

    return (train_x, train_t), (test_x, test_t), (valid_x, valid_t)
Download the SVHN dataset if it is not present.
dataset/ETHPy150Open larsmaaloee/auxiliary-deep-generative-models/data_loaders/svhn.py/_download