Description
In this project you will re-implement the character recognition from Project 1 using Keras to build a multilayer network.
The project may be completed individually, or in a group of no more than three (3) students.
Platforms
The platform requirements for this project are the same as for Project 1.
Libraries and Code
This project should use the NumPy and Keras libraries.
Code from A Whirlwind Tour of Python and from the library documentation may be reused. All other code and the results of experiments must be your own original work or the original work of other members of your team.
Dataset
This project uses the same dataset as Project 1. You do not need to have completed Project 1 in order to complete this project.
Experiments
Run the following experiments in a Jupyter notebook, performing each action in a code cell and answering each question in a Markdown cell.
- Use from dataset import * to load the module, then examine TRAINING_SET, TEST_SET, and MESSAGE.
- In order to use the images in TRAINING_SET, TEST_SET, and MESSAGE, convert them into two-dimensional NumPy arrays of feature vectors.
In order to evaluate the output of your code, you may wish to consider implementing a Python function show(image) to print() a letter image row-by-row using a hash mark (‘#’) for 1 and a space (‘ ‘) for 0 and testing this function on some of the images in TRAINING_SET.
- In order to use the character labels in TRAINING_SET and TEST_SET, convert them into an integer class vector using ord(), then into 26 one-hot encoded categorical features.
- Create a Sequential Keras model with a Dense hidden layer and a Dense output layer with softmax activation.
- compile and fit the model to the training set. Train the model until the accuracy is as high as possible. You may wish to use an EarlyStopping callback.
- evaluate the model on TEST_SET. What accuracy do you obtain? If the accuracy is less than 100%, which test images are misclassified?
- Use your trained model and chr() to identify the letters in MESSAGE. What does it say in English? (Note that there are no spaces between words.) Why do you suppose this was chosen as the message?
If you completed Project 1, how does this model compare with the performance of your perceptron models? Were any letters misclassified?
- All of the letters in MESSAGE were likely not decoded correctly, so let’s try to improve the performance of the model by adding additional hidden layers. Add two additional hidden layers of the same size as your original hidden layer, then repeat experiments (5) and (7). Does the performance improve?
- Repeat experiment (8), adding additional layers of the same size until the message is decoded correctly. What results do you observe?
Submission
A Markdown cell at the top of the notebook should include project summary information as described in the Syllabus for README files.
Since you may be actively editing and making changes to the code cells in your notebook, be certain that each of your code cells still runs correctly before submission. You may wish to do this by selecting Run All from the drop-down menu bar.
Submit your Jupyter .ipynb notebook file through Canvas before class on the due date.
If the assignment is completed by a team, only one submission is required. Be certain to identify the names of all students on your team at the top of the notebook. See the following sections of the Canvas documentation for instructions on group submission: