Building an optical character recognizer using neural networks
Now that we know how to interact with the data, let's build a neural network-based optical character-recognition system.
How to do it…
- Create a new Python file, and import the following packages:
import numpy as np import neurolab as nl
- Define the input filename:
# Input file input_file = 'letter.data'
- When we work with neural networks that deal with large amounts of data, it takes a lot of time to train. To demonstrate how to build this system, we will take only
20
datapoints:# Number of datapoints to load from the input file num_datapoints = 20
- If you look at the data, you will see that there are seven distinct characters in the first 20 lines. Let's define them:
# Distinct characters orig_labels = 'omandig' # Number of distinct characters num_output = len(orig_labels)
- We will use 90% of the data for training and remaining 10% for testing. Define the training and testing parameters:
# Training and...