O'Reilly logo

Artificial Intelligence with Python by Prateek Joshi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required