Building an image classifier using a Convolutional Neural Network
The image classifier in the previous section didn't perform well. Getting 92.1% on MNIST dataset is relatively easy. Let's see how we can use Convolutional Neural Networks (CNNs) to achieve a much higher accuracy. We will build an image classifier using the same dataset, but with a CNN instead of a single layer neural network.
Create a new python and import the following packages:
import argparse import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data
Define a function to parse the input arguments:
def build_arg_parser(): parser = argparse.ArgumentParser(description='Build a CNN classifier \ using MNIST data') parser.add_argument('--input-dir', dest='input_dir', type=str, default='./mnist_data', help='Directory for storing data') return parser
Define a function to create values for weights in...