當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。