1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Deep Learning with Keras

Connected

Exercise

Learning the digits

You're going to build a model on the digits dataset, a sample dataset that comes pre-loaded with scikit learn. The digits dataset consist of 8x8 pixel handwritten digits from 0 to 9:

You want to distinguish between each of the 10 possible digits given an image, so we are dealing with multi-class classification.

The dataset has already been partitioned into X_train, y_train, X_test, and y_test, using 30% of the data as testing data. The labels are already one-hot encoded vectors, so you don't need to use Keras to_categorical() function.

Let's build this new model!

Instructions

100 XP
  • Add a Dense layer of 16 neurons with relu activation and an input_shape that takes the total number of pixels of the 8x8 digit image.
  • Add a Dense layer with 10 outputs and softmax activation.
  • Compile your model with adam, categorical_crossentropy, and accuracy metrics.
  • Make sure your model works by predicting on X_train.