from keras.preprocessing.image import ImageDataGenerator from pnslib import utils from pnslib import ml datagen = ImageDataGenerator(featurewise_center=True, featurewise_std_normalization=True, rotation_range=20, width_shift_range=0.2, height_shift_range=0.2, horizontal_flip=True) # Load all the ten classes from Fashion MNIST # complete label description is at # https://github.com/zalandoresearch/fashion-mnist#labels (train_x, train_y, test_x, test_y) = utils.fashion_mnist_load(data_type="full", flatten=False) num_classes = 10 print("[MESSAGE] Dataset is loaded.") # preprocessing for training and testing images train_x = train_x.astype("float32") / 255. # rescale image mean_train_x = np.mean(train_x, axis=0) # compute the mean across pixels train_x -= mean_train_x # remove the mean pixel value from image test_x = test_x.astype("float32") / 255. test_x -= mean_train_x print("[MESSAGE] Dataset is preprocessed.") print(test_x.shape)
"""Demonstrate the usage of Fashion-MNIST. Author: Yuhuang Hu Email : [email protected] """ from __future__ import print_function, absolute_import import matplotlib.pyplot as plt import pnslib.utils as utils (train_x, train_y, test_x, test_y) = utils.fashion_mnist_load("full") print(train_x.shape) print(train_y.shape) print(test_x.shape) print(test_y.shape) plt.figure() for idx in range(100): plt.imshow(test_x[idx, ..., 0], cmap="gray") plt.show()