Python keras.datasets.fashion_mnist.load_data() Examples
The following are 30
code examples of keras.datasets.fashion_mnist.load_data().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
keras.datasets.fashion_mnist
, or try the search function
.
Example #1
Source File: utils.py From ResNet-Tensorflow with MIT License | 7 votes |
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
Example #2
Source File: 05_nn_vis.py From Practical-Computer-Vision with MIT License | 6 votes |
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
Example #3
Source File: utils.py From ResNet-Tensorflow with MIT License | 6 votes |
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
Example #4
Source File: utils.py From ResNet-Tensorflow with MIT License | 6 votes |
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
Example #5
Source File: utils.py From ResNet-Tensorflow with MIT License | 6 votes |
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
Example #6
Source File: fashion_mnist_multi_task_learning.py From Cross-stitch-Networks-for-Multi-task-Learning with MIT License | 6 votes |
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
Example #7
Source File: 05_nn_mnist.py From Practical-Computer-Vision with MIT License | 6 votes |
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
Example #8
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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
Example #9
Source File: capsulenet.py From CapsNet-Fashion-MNIST with MIT License | 5 votes |
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)
Example #10
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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
Example #11
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #12
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #13
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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
Example #14
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #15
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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
Example #16
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #17
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #18
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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
Example #19
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #20
Source File: utils.py From AnomalyDetectionTransformations with MIT License | 5 votes |
def load_fashion_mnist(): (X_train, y_train), (X_test, y_test) = fashion_mnist.load_data() X_train = normalize_minus1_1(cast_to_floatx(np.pad(X_train, ((0, 0), (2, 2), (2, 2)), 'constant'))) X_train = np.expand_dims(X_train, axis=get_channels_axis()) X_test = normalize_minus1_1(cast_to_floatx(np.pad(X_test, ((0, 0), (2, 2), (2, 2)), 'constant'))) X_test = np.expand_dims(X_test, axis=get_channels_axis()) return (X_train, y_train), (X_test, y_test)
Example #21
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #22
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #23
Source File: test_datasets.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #24
Source File: utils.py From AnomalyDetectionTransformations with MIT License | 5 votes |
def load_cifar100(label_mode='coarse'): (X_train, y_train), (X_test, y_test) = cifar100.load_data(label_mode=label_mode) X_train = normalize_minus1_1(cast_to_floatx(X_train)) X_test = normalize_minus1_1(cast_to_floatx(X_test)) return (X_train, y_train), (X_test, y_test)
Example #25
Source File: utils.py From AnomalyDetectionTransformations with MIT License | 5 votes |
def load_cifar10(): (X_train, y_train), (X_test, y_test) = cifar10.load_data() X_train = normalize_minus1_1(cast_to_floatx(X_train)) X_test = normalize_minus1_1(cast_to_floatx(X_test)) return (X_train, y_train), (X_test, y_test)
Example #26
Source File: utils.py From AnomalyDetectionTransformations with MIT License | 5 votes |
def load_mnist(): (X_train, y_train), (X_test, y_test) = mnist.load_data() X_train = normalize_minus1_1(cast_to_floatx(np.pad(X_train, ((0, 0), (2, 2), (2, 2)), 'constant'))) X_train = np.expand_dims(X_train, axis=get_channels_axis()) X_test = normalize_minus1_1(cast_to_floatx(np.pad(X_test, ((0, 0), (2, 2), (2, 2)), 'constant'))) X_test = np.expand_dims(X_test, axis=get_channels_axis()) return (X_train, y_train), (X_test, y_test)
Example #27
Source File: load_datasets.py From deepcaps with MIT License | 5 votes |
def load_cifar10(): from keras.datasets import cifar10 (x_train, y_train), (x_test, y_test) = cifar10.load_data() x_train = x_train.reshape(-1, 32, 32, 3).astype('float32') / 255. x_test = x_test.reshape(-1, 32, 32, 3).astype('float32') / 255. # mean = np.mean(x_train, axis=(0,1,2)) # x_train -= mean # x_test -= mean y_train = to_categorical(y_train.astype('float32')) y_test = to_categorical(y_test.astype('float32')) # return (x_train[0:100], y_train[0:100]), (x_test[0:100], y_test[0:100]) return (x_train, y_train), (x_test, y_test)
Example #28
Source File: load_datasets.py From deepcaps with MIT License | 5 votes |
def load_cifar100(): from keras.datasets import cifar100 (x_train, y_train), (x_test, y_test) = cifar100.load_data() x_train = x_train.reshape(-1, 32, 32, 3).astype('float32') / 255. x_test = x_test.reshape(-1, 32, 32, 3).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)
Example #29
Source File: load_datasets.py From deepcaps with MIT License | 5 votes |
def load_mnist(): # the data, shuffled and split between train and test sets from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = 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)
Example #30
Source File: load_datasets.py From deepcaps with MIT License | 5 votes |
def load_fmnist(): # the data, shuffled and split between train and test sets from keras.datasets import 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)