Improving the clothing image classifier with data augmentation
Armed with several common augmentation methods, we now apply them to train our image classifier on a small dataset in the following steps:
- We start by constructing a small training set:
>>> n_small = 500 >>> X_train = X_train[:n_small] >>> train_labels = train_labels[:n_small] >>> print(X_train.shape) (500, 28, 28, 1)
We only use 500 samples for training.
- We architect the CNN model using the Keras Sequential API:
>>> model = models.Sequential() >>> model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1))) >>> model.add(layers.MaxPooling2D((2, 2))) >>> model.add(layers.Conv2D(64, (3, 3), activation='relu')) >>> model.add(layers.Flatten()) >>> model.add(layers.Dense(32, activation='relu')) >>> model.add(layers.Dense(10, activation...