7. Convolutional Neural Networks
Activity 7.01: Building a CNN with More ANN Layers
Solution:
There are several possible ways to arrive at a solution for this activity. The following steps describe one of these methods and are similar to those used on the CIFAR-10
dataset earlier in the chapter:
- Start a new Jupyter notebook.
- Import the TensorFlow library:
import tensorflow as tf
- Import the additional libraries needed:
import numpy as np import matplotlib.pyplot as plt import tensorflow as tf import tensorflow_datasets as tfds from tensorflow.keras.layers import Input, Conv2D, Dense, Flatten, \ Dropout, Activation, Rescaling from tensorflow.keras.models import Model from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
- Load the
CIFAR-100
dataset directly fromtensorflow_datasets
and view its properties:(c100_train_dataset, c100_test_dataset), \ dataset_info = tfds.load('cifar100',\ ...