Building an image classifier using a single layer neural network

Let's see how to create a single layer neural network using TensorFlow and use it to build an image classifier. We will be using MNIST image dataset to build our system. It is dataset containing handwritten images of digits. Our goal is to build a classifier that can correctly identify the digit in each image.

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 classifier using \MNIST data')     parser.add_argument('--input-dir', dest='input_dir', type=str, ...

Get Artificial Intelligence with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.