Now we will learn how to build a CNN using TensorFlow. We will use the MNIST handwritten digits dataset and understand how a CNN recognizes handwritten digits, and we will also visualize how the convolutional layers extract important features from the image.
First, let's load the required libraries:
import warnings
warnings.filterwarnings('ignore')
import numpy as np
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
tf.logging.set_verbosity(tf.logging.ERROR)
import matplotlib.pyplot as plt
%matplotlib inline
Load the MNIST dataset:
mnist = input_data.read_data_sets('data/mnist', one_hot=True)