Recognizing CIFAR-10 images with deep learning
The CIFAR-10 dataset contains 60,000 color images of 32×32 pixels in 3 channels, divided in 10 classes. Each class contains 6,000 images. The training set contains 50,000 images, while the test sets provides 10,000 images. This image taken from the CIFAR repository (https://www.cs.toronto.edu/~kriz/cifar.html) shows a few random examples from each of the 10 classes:
Figure 12: An example of CIFAR-10 images
The goal is to recognize previously unseen images and assign them to one of the 10 classes. Let us define a suitable deep net.
First of all, we import a number of useful modules, define a few constants, and load the dataset (the full code including the load operations is available online):
import tensorflow as tf
from tensorflow.keras import datasets, layers, models, optimizers
# CIFAR_10 is a set of 60K images 32x32 pixels on 3 channels
IMG_CHANNELS = 3
IMG_ROWS = 32
IMG_COLS = 32
# constant
BATCH_SIZE = 128
EPOCHS...