The Fashion
Instead of handwritten digits, it contains 70000 28x28 grayscale images of ten types of fashion items.
The training set has 60,000 images while the test set has 10,000. This dataset has been widely used in deep learning as it has been standardized and can represent modern computer vision tasks.
The fashion categories are as follows.
Category | Label |
Top/T-shirt | 0 |
Trouser | 1 |
Pullover | 2 |
Dress | 3 |
Coat | 4 |
Sandal | 5 |
Shirt | 6 |
Sneaker | 7 |
Bag | 8 |
Ankle Boot | 9 |
load_data()
functionThe load_data()
function is used to load the dataset from Keras.
tf.keras.datasets.fashion_mnist.load_data(path='fmnist.npz')
path
: the relative path where to cache the dataset locally. This parameter is optional.It returns two tuples with NumPy arrays. The tuples are in the form (X_train, y_train), (X_test, y_test)
.
X_train
: Training data that consists of grayscale images. It has the shape (60000, 28, 28) and the uint8
. The pixel values vary from 0 to 255.
y_train
: Training labels that consist of integers from 0-9 with the dtype of uint8
. Each label corresponds to a fashion category. It has the shape (60000,).
X_test
: Testing data that consists of grayscale images. It has the shape (10000, 28, 28) and dtype of uint8
. The pixel values vary from 0 to 255.
y_test
: Testing labels that consist of integers from 0-9 with the dtype of uint8
. Each label corresponds to a fashion category. It has the shape (10000,).
import tensorflow as tf(X_train, y_train), (X_test, y_test) = tf.keras.datasets.fashion_mnist.load_data()print('Shape of X_train: ', X_train.shape)print('Shape of y_train: ', y_train.shape)print('Shape of X_test: ', X_test.shape)print('Shape of y_test: ', y_test.shape)