We can access fashion-MNIST data from Keras using thedataset_fashion_mnist function. Take a look at the following code and its output:
# MNIST data
mnist <- dataset_fashion_mnist()
str(mnist)
OUTPUT
List of 2 $ train:List of 2 ..$ x: int [1:60000, 1:28, 1:28] 0 0 0 0 0 0 0 0 0 0 ... ..$ y: int [1:60000(1d)] 9 0 0 3 0 2 7 2 5 5 ... $ test :List of 2 ..$ x: int [1:10000, 1:28, 1:28] 0 0 0 0 0 0 0 0 0 0 ... ..$ y: int [1:10000(1d)] 9 2 1 1 6 1 4 6 5 7 ...
Looking at the structure of the preceding data, we see that it contains train data with 60,000 images and test data with 10,000 images. All these images are 28 x 28 grayscale images. We know from the previous chapter that images can be represented as numeric data based on color and intensity. The independent variable x contains the intensity values, and the dependent variable y contains labels from 0 to 9.
The 10 different fashion items in the fashion-MNIST dataset are labelled from 0 to 9, as shown in the following table:
Label | Description |
---|---|
0 | T-shirt/Top |
1 | Trouser |
2 | Pullover |
3 | Dress |
4 | Coat |
5 | Sandal |
6 | Shirt |
7 | Sneaker |
8 | Bag |
9 | Ankle Boot |
Looking at the preceding table, we may observe that developing a classification model for these images will be challenging as some categories will be difficult to differentiate.