示例#1
0
文件: demo.py 项目: tuanrpt/DualSVRG
def load_mnist(shuffle_data=True, randseed='default'):
    train_path = get_file("mnist_train.libsvm", origin=remote_data_dir() + "/mnist_train.libsvm",
                          cache_subdir="demo")
    test_path = get_file("mnist_test.libsvm", origin=remote_data_dir() + "/mnist_test.libsvm",
                         cache_subdir="demo")

    x_train, y_train = load_svmlight_file(train_path, n_features=784)
    x_test, y_test = load_svmlight_file(test_path, n_features=784)
    x_train = x_train.toarray() / 255.0
    x_test = x_test.toarray() / 255.0

    if shuffle_data:
        shuffle(x_train, y_train, randseed=randseed)

    return (x_train, y_train), (x_test, y_test)
示例#2
0
文件: demo.py 项目: tuanrpt/DualSVRG
def load_cifar10(shuffle_data=True, randseed='default'):
    train_path = get_file("cifar10_5k_train.pkl",
                          origin=remote_data_dir() + "/cifar10_5k_train.pkl",
                          cache_subdir="demo")
    test_path = get_file("cifar10_1k_test.pkl",
                         origin=remote_data_dir() + "/cifar10_1k_test.pkl",
                         cache_subdir="demo")

    tmp = pickle.load(open(train_path, "rb"))
    x_train, y_train = tmp['data'] / 255.0, tmp['labels']
    tmp = pickle.load(open(test_path, "rb"))
    x_test, y_test = tmp['data'] / 255.0, tmp['labels']

    if shuffle_data:
        shuffle(x_train, y_train, randseed=randseed)

    return (x_train, y_train), (x_test, y_test)
示例#3
0
文件: demo.py 项目: tuanrpt/DualSVRG
def load_housing(shuffle_data=True, randseed='default'):
    train_path = get_file("housing_scale_train.libsvm",
                          origin=remote_data_dir() + "/housing_scale_train.libsvm",
                          cache_subdir="demo")
    test_path = get_file("housing_scale_test.libsvm",
                         origin=remote_data_dir() + "/housing_scale_test.libsvm",
                         cache_subdir="demo")

    x_train, y_train = load_svmlight_file(train_path, n_features=13)
    x_test, y_test = load_svmlight_file(test_path, n_features=13)
    x_train = x_train.toarray()
    x_test = x_test.toarray()

    if shuffle_data:
        shuffle(x_train, y_train, randseed=randseed)

    return (x_train, y_train), (x_test, y_test)