当前位置: 首页>>代码示例>>Python>>正文


Python fashion_mnist.load_data方法代码示例

本文整理汇总了Python中keras.datasets.fashion_mnist.load_data方法的典型用法代码示例。如果您正苦于以下问题:Python fashion_mnist.load_data方法的具体用法?Python fashion_mnist.load_data怎么用?Python fashion_mnist.load_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keras.datasets.fashion_mnist的用法示例。


在下文中一共展示了fashion_mnist.load_data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_cifar10

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def load_cifar10() :
    (train_data, train_labels), (test_data, test_labels) = cifar10.load_data()
    # train_data = train_data / 255.0
    # test_data = test_data / 255.0

    train_data, test_data = normalize(train_data, test_data)

    train_labels = to_categorical(train_labels, 10)
    test_labels = to_categorical(test_labels, 10)

    seed = 777
    np.random.seed(seed)
    np.random.shuffle(train_data)
    np.random.seed(seed)
    np.random.shuffle(train_labels)


    return train_data, train_labels, test_data, test_labels 
开发者ID:taki0112,项目名称:ResNet-Tensorflow,代码行数:20,代码来源:utils.py

示例2: load_cifar100

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def load_cifar100() :
    (train_data, train_labels), (test_data, test_labels) = cifar100.load_data()
    # train_data = train_data / 255.0
    # test_data = test_data / 255.0
    train_data, test_data = normalize(train_data, test_data)

    train_labels = to_categorical(train_labels, 100)
    test_labels = to_categorical(test_labels, 100)

    seed = 777
    np.random.seed(seed)
    np.random.shuffle(train_data)
    np.random.seed(seed)
    np.random.shuffle(train_labels)


    return train_data, train_labels, test_data, test_labels 
开发者ID:taki0112,项目名称:ResNet-Tensorflow,代码行数:19,代码来源:utils.py

示例3: load_mnist

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def load_mnist() :
    (train_data, train_labels), (test_data, test_labels) = mnist.load_data()
    train_data = np.expand_dims(train_data, axis=-1)
    test_data = np.expand_dims(test_data, axis=-1)

    train_data, test_data = normalize(train_data, test_data)

    train_labels = to_categorical(train_labels, 10)
    test_labels = to_categorical(test_labels, 10)

    seed = 777
    np.random.seed(seed)
    np.random.shuffle(train_data)
    np.random.seed(seed)
    np.random.shuffle(train_labels)


    return train_data, train_labels, test_data, test_labels 
开发者ID:taki0112,项目名称:ResNet-Tensorflow,代码行数:20,代码来源:utils.py

示例4: load_fashion

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def load_fashion() :
    (train_data, train_labels), (test_data, test_labels) = fashion_mnist.load_data()
    train_data = np.expand_dims(train_data, axis=-1)
    test_data = np.expand_dims(test_data, axis=-1)

    train_data, test_data = normalize(train_data, test_data)

    train_labels = to_categorical(train_labels, 10)
    test_labels = to_categorical(test_labels, 10)

    seed = 777
    np.random.seed(seed)
    np.random.shuffle(train_data)
    np.random.seed(seed)
    np.random.shuffle(train_labels)


    return train_data, train_labels, test_data, test_labels 
开发者ID:taki0112,项目名称:ResNet-Tensorflow,代码行数:20,代码来源:utils.py

示例5: load_data

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def load_data():
    # train_X: (60000, 28, 28)
    # train_y: (60000,)
    # test_X: (10000, 28, 28)
    # test_y: (10000,)
    (train_X, train_y_1), (test_X, test_y_1) = fashion_mnist.load_data()
    n_class_1 = 10
    # map to new label
    train_y_2 = list(0 if y in [5, 7, 9] else 1 if y in [3, 6, 8] else 2 for y in train_y_1)
    test_y_2 = list(0 if y in [5, 7, 9] else 1 if y in [3, 6, 8] else 2 for y in test_y_1)
    n_class_2 = 3
    # train_X: (60000, 28, 28, 1)
    # test_X: (10000, 28, 28, 1)
    # train_y: (60000, n_class)
    # test_y: (10000, n_class)
    train_X = np.expand_dims(train_X, axis=3)
    test_X = np.expand_dims(test_X, axis=3)
    train_y_1 = to_categorical(train_y_1, n_class_1)
    test_y_1 = to_categorical(test_y_1, n_class_1)
    train_y_2 = to_categorical(train_y_2, n_class_2)
    test_y_2 = to_categorical(test_y_2, n_class_2)
    return train_X, train_y_1, train_y_2, test_X, test_y_1, test_y_2 
开发者ID:helloyide,项目名称:Cross-stitch-Networks-for-Multi-task-Learning,代码行数:24,代码来源:fashion_mnist_multi_task_learning.py

示例6: get_dataset

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def get_dataset():
    """
    Return processed and reshaped dataset for training
    In this cases Fashion-mnist dataset.
    """
    # load mnist dataset
    (x_train, y_train), (x_test, y_test) = fashion_mnist.load_data()
    
    # test and train datasets
    print("Nb Train:", x_train.shape[0], "Nb test:",x_test.shape[0])
    x_train = x_train.reshape(x_train.shape[0], img_h, img_w, 1)
    x_test = x_test.reshape(x_test.shape[0], img_h, img_w, 1)
    in_shape = (img_h, img_w, 1)

    # normalize inputs
    x_train = x_train.astype('float32')
    x_test = x_test.astype('float32')
    x_train /= 255.0
    x_test /= 255.0

    # convert to one hot vectors 
    y_train = keras.utils.to_categorical(y_train, nb_class)
    y_test = keras.utils.to_categorical(y_test, nb_class)
    return x_train, x_test, y_train, y_test 
开发者ID:PacktPublishing,项目名称:Practical-Computer-Vision,代码行数:26,代码来源:05_nn_mnist.py

示例7: load_mnist

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def load_mnist():
    # the data, shuffled and split between train and test sets
    from keras.datasets import mnist, fashion_mnist
    (x_train, y_train), (x_test, y_test) = fashion_mnist.load_data()

    x_train = x_train.reshape(-1, 28, 28, 1).astype('float32') / 255.
    x_test = x_test.reshape(-1, 28, 28, 1).astype('float32') / 255.
    y_train = to_categorical(y_train.astype('float32'))
    y_test = to_categorical(y_test.astype('float32'))
    return (x_train, y_train), (x_test, y_test) 
开发者ID:XifengGuo,项目名称:CapsNet-Fashion-MNIST,代码行数:12,代码来源:capsulenet.py

示例8: load_mnist

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def load_mnist():
    (x_train, y_train), (x_test, y_test) = mnist.load_data()
    x = np.concatenate((x_train, x_test))
    y = np.concatenate((y_train, y_test))
    x = x.reshape((x.shape[0], -1))
    x = np.divide(x, 255.)
    return x, y 
开发者ID:rymc,项目名称:n2d,代码行数:9,代码来源:datasets.py

示例9: load_mnist_test

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def load_mnist_test():
    (x_train, y_train), (x_test, y_test) = mnist.load_data()
    x = x_test
    y = y_test
    x = np.divide(x, 255.)
    x = x.reshape((x.shape[0], -1))
    return x, y 
开发者ID:rymc,项目名称:n2d,代码行数:9,代码来源:datasets.py

示例10: load_fashion

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def load_fashion():
    (x_train, y_train), (x_test, y_test) = fashion_mnist.load_data()
    x = np.concatenate((x_train, x_test))
    y = np.concatenate((y_train, y_test))
    x = x.reshape((x.shape[0], -1))
    x = np.divide(x, 255.)
    y_names = {0: "T-shirt", 1: "Trouser", 2: "Pullover", 3: "Dress", 4: "Coat",
               5: "Sandal", 6: "Shirt", 7: "Sneaker", 8: "Bag", 9: "Ankle Boot"}
    return x, y, y_names 
开发者ID:rymc,项目名称:n2d,代码行数:11,代码来源:datasets.py

示例11: test_cifar

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def test_cifar():
    # only run data download tests 20% of the time
    # to speed up frequent testing
    random.seed(time.time())
    if random.random() > 0.8:
        (x_train, y_train), (x_test, y_test) = cifar10.load_data()
        assert len(x_train) == len(y_train) == 50000
        assert len(x_test) == len(y_test) == 10000
        (x_train, y_train), (x_test, y_test) = cifar100.load_data('fine')
        assert len(x_train) == len(y_train) == 50000
        assert len(x_test) == len(y_test) == 10000
        (x_train, y_train), (x_test, y_test) = cifar100.load_data('coarse')
        assert len(x_train) == len(y_train) == 50000
        assert len(x_test) == len(y_test) == 10000 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:16,代码来源:test_datasets.py

示例12: test_reuters

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def test_reuters():
    # only run data download tests 20% of the time
    # to speed up frequent testing
    random.seed(time.time())
    if random.random() > 0.8:
        (x_train, y_train), (x_test, y_test) = reuters.load_data()
        assert len(x_train) == len(y_train)
        assert len(x_test) == len(y_test)
        assert len(x_train) + len(x_test) == 11228
        (x_train, y_train), (x_test, y_test) = reuters.load_data(maxlen=10)
        assert len(x_train) == len(y_train)
        assert len(x_test) == len(y_test)
        word_index = reuters.get_word_index()
        assert isinstance(word_index, dict) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:16,代码来源:test_datasets.py

示例13: test_mnist

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def test_mnist():
    # only run data download tests 20% of the time
    # to speed up frequent testing
    random.seed(time.time())
    if random.random() > 0.8:
        (x_train, y_train), (x_test, y_test) = mnist.load_data()
        assert len(x_train) == len(y_train) == 60000
        assert len(x_test) == len(y_test) == 10000 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:10,代码来源:test_datasets.py

示例14: test_imdb

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def test_imdb():
    # only run data download tests 20% of the time
    # to speed up frequent testing
    random.seed(time.time())
    if random.random() > 0.8:
        (x_train, y_train), (x_test, y_test) = imdb.load_data()
        (x_train, y_train), (x_test, y_test) = imdb.load_data(maxlen=40)
        assert len(x_train) == len(y_train)
        assert len(x_test) == len(y_test)
        word_index = imdb.get_word_index()
        assert isinstance(word_index, dict) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:13,代码来源:test_datasets.py

示例15: test_boston_housing

# 需要导入模块: from keras.datasets import fashion_mnist [as 别名]
# 或者: from keras.datasets.fashion_mnist import load_data [as 别名]
def test_boston_housing():
    # only run data download tests 20% of the time
    # to speed up frequent testing
    random.seed(time.time())
    if random.random() > 0.8:
        (x_train, y_train), (x_test, y_test) = boston_housing.load_data()
        assert len(x_train) == len(y_train)
        assert len(x_test) == len(y_test) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:10,代码来源:test_datasets.py


注:本文中的keras.datasets.fashion_mnist.load_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。