Creating a CNN to recognize digits
In the following section, we will use Keras. Keras is a Python library for neural networks and provides a high-level interface to TensorFlow libraries. We do not intend to give a complete tutorial on Keras or CNN, but we want to show how we can use Matplotlib to visualize the loss
function, accuracy
, and outliers of the results.
Readers who are not familiar with machine learning should be able to go through the logic of the remaining chapter and hopefully understand why visualizing the loss
function, accuracy
, and outliers of the results is important in fine-tuning the CNN model.
Here is a snippet of code for the CNN; the most important part is the evaluation section after this!
# Import sklearn models for preprocessing input data from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelBinarizer # Import the necessary Keras libraries from keras.models import Sequential from keras.layers import Dense, Dropout, Flatten...